SetDestination can only be called on an active agent that is on a NavMesh.
So I've ran into a little problem with my tank game. The tanks both spawn perfectly for the first/starting round, but after the enemy kills the player or vice versa, the enemytank respawns where it should and just sits there and gives me this error
"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.NavMeshAgent:SetDestination(Vector3)
EnemyInfo.EnemyMovement:Update() (at Assets/Scripts/EnemyTank/EnemyMovement.cs:45)
I'm not quite sure how to go about fixing this. The Tanks! Tutorial on Unity's website is what I based my game off of, but I created a little AI to make it a singleplayer game. Any help?
If you would like to see all of the classes, Here is the Github link.
Answer by sebastiao_lucio · Jan 18, 2017 at 01:58 PM
Hello @ltrout1999! I had the same problem in the game I'm building for the game that I will teach "lego crossy road" on my channel SLTutorias on youtubehttps://www.youtube.com/channel/UClRHrHeybIcPVo-t6Jq8cnQ. There are two possible problems:
1º)In your scene click on a mesh or train and then in Window tabs select navigation... Now u can see navigation layout beside the inspector... Just in bake tab of navigation click the bottom button that says Bake... And you're done
If you have already done this and the problem persists:
2) probably the point where your gameobject is being instantiated outside the reach area of ??the mesh (terrain or plane or quad). Change the position of the spaw point into the area of ??the mesh.experiment by putting this spaw point in the center of the terrain to see. I hope I have helped! Good luck! Sincerely, SLTutorias
this is super useful! clicking bake worked for me, thank you!
Answer by najemzoabie40 · Oct 23, 2019 at 08:54 AM
You can try to set the plane as static, check the box in the inspector.
Answer by Moutik · Jan 04, 2020 at 03:40 PM
"probably the point where your gameobject is being instantiated outside the reach area of the navmesh" => that did it for me, even though the gameobject was moved on a walkable area afterwards. It needs to be instantiated inside in the first place.
Your answer
![](https://koobas.hobune.stream/wayback/20220612055720im_/https://answers.unity.com/themes/thub/images/avi.jpg)