Setdestination method error

During my “add zombies” exercise for the zombie runner section, I have encountered this error “SetDestination” can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.AI.NavMeshAgent: SetDestination(Vector3)" I did everything as said but as my enemy is about to die this happens.
what should I do?

Hi,

Have you already tried to rebake the navmesh? Are there any other error messages in your console?

Hello,
I have rebaked the navmesh multiple times and there are no other errors in my logs other than this one, and the funny thing is if I kill the enemy with one shot before it moves everything is ok but as it starts moving and I kill him during walking the error happens but sometimes when I one-shot him during chasing no error pups up, so weird

This sounds as if there might be a problem with the execution order. The execution order in Unity is arbitrary. Since you mentioned that the issue sometimes does not occur when you one-shot the enemy, I would suggest to add Debug.Logs to your code.

If you destroy the enemy with Destroy, disable the enemy with {reference to enemy GameObject}.SetActive(false); because Destroy does not destroy immediately.

If you placed the zombie manually, move it a bit up, so it floats a few “pixels” above the navmesh. Maybe it is currently stuck inside the mesh.

Thanks, I’ll try and inform you the results

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms