Page 1 of 1

Spawning Game Object

Posted: Fri Oct 08, 2021 1:16 pm
by Mach4
Hello Tony -

In my "Collection" quest, I am spawning 3 objects using spawn points. For testing I am using three cubes with the mesh turned off. I get an object to spawn, but it does not always spawn in the same location within the "Spawn location" game object (Cube). Is there a way to fine tune that ?


Thanks
RIck

Re: Spawning Game Object

Posted: Fri Oct 08, 2021 1:41 pm
by Tony Li
Hi Rick,

If your Spawner's Position Info > Position Type is set to Spawnpoints, then it will choose one of the spawnpoints you've assigned to the Spawnpoints list. Then it will move the spawned object to the exact same position and rotation as the spawnpoint.

If the object has a NavMeshAgent (e.g., an NPC that can move around), it will move the object using NavMeshAgent.Warp(), which keeps the object on a navmesh. If the object isn't exactly on the spawnpoint, maybe NavMeshAgent.Warp() is adjusting the position to keep it on a navmesh.

Otherwise, if it doesn't have a NavMeshAgent, it will assign the transform position directly (i.e., transform.position = spawnpoint.transform.position). If the object isn't exactly on the spawnpoint, maybe the physics simulation is causing it to fall to the ground or otherwise teeter off position.

Re: Spawning Game Object

Posted: Fri Oct 08, 2021 1:59 pm
by Mach4
There is no a navmesh issue, so it must be a physics issue. Had not thought about that and I will check that out.


Thanks
Rick