When I add a Nav Mesh Agent to my enemy it disappears when I press ⏵ Play. When I take the Nav Mesh Agent component off everything works fine and I can see the enemy.
4 Answers
4Breaking new! Just add:
Awake ()
{
agent.updateRotation = false;
agent.updateUpAxis = false;
}
It will fix the problem!
Not sure if by “Nav Mesh component” you mean NavMeshAgent or NavMeshSurface, but you should never add NavMeshSurface to an enemy – that’s for the environment.
As for why adding NavMeshAgent makes the enemy disappear, it could be that he’s just teleporting to the nearest NavMeshSurface upon play.
After you start the game and the enemy disappears, select the enemy in the editor, put your cursor over the scene view, and press f on your keyboard. this will move your view to the enemy, so you can see where it is.
I know this question is almost a year old and I’m late to responding, but I thought I would leave this response here in case someone else ran into this issue.
If your Nav Mesh Agents are disappearing at runtime, it could be because you haven’t set the Nav Mesh Agent set Update Rotation & Set Update Up Axis to false. This was the case for me!
Hope it helps!
The solution above didn’t quite fix my issue. I also needed to have the Base Offset be lower than 1, in addition to the above step.
Hey there, can you please specify what "dissappear" means? deleted? misplaced?
– Captain_PineappleCan you be more precise? Do you see error logs?
– lgarczyn