Spawnning Agents are not working

Hi guys.

I’m working on a project where NPC are spawn randomly in time. The problem I’ve found is that if I spawn an enemy after the surface has been baked, the NPC doesn’t move.

I tried to bake the surface every time a NPC is spawn, but that creates an extra random movement to the rest of NPC that are already over the surface.

By the way, my game is developed using ARKit and all playing action is in an area of 2 by 2. That makes the NPC’s very small in scale. I don’t think that this has relation with the problem but I think is an important extra information.

Any suggestions are appreciated.

My guess is that your agent is not exactly on the mesh. I solved this issue by in the start method first warping the character up a unit or two, then finding the closest navmesh point to that, and snapping it to it.

1 Like

My game uses half of its pathfinding by Navmesh, and half just override and making the Enemy react to it’s target, ignoring Navmesh constraints. For Example, if the player gets to place where the navmesh isn’t baked or it’s too small, than your navmesh enemy is broken. But maybe I can help.

The navmesh agent, when it SPAWNS or when the scene is started in it, will check if it’s on or near-enough to a Navmesh to be an active Navmesh Agent. If it is not, it will stop working immediately and is hard to restart. Check your Console for errors. I recommend using Warping like newjerseyrunner said, because it fixes the placement of your navmesh agent to the transform position.

1 Like

Thank you… that was it.

1 Like

Very common mistake. It took me forever to figure that out.