- Home /
Toggling NavMeshAgent and NavMeshObstacle
I am close to giving up on the built in Nav components of unity and just building my own. I am building an RTS game, and pathing is very very important.
The closest I have been able to get to my goal is by toggling the NavMeshAgent and NavMeshObstacle on and off. However, when the Obstacle is disabled, it does not update the navmesh fast enough, and the agent jumps from its location.
Is there something I can tap into to see when the navmesh has updated so I can wait to enable my agent
Currently facing the same problem. Could you eventually find a solution?
Answer by OptimusPwnius · Jun 22, 2018 at 05:31 AM
I solved this by toggling the agent and the obstacle in two different Updates().
So on the first Update() loop, the agent is disabled, the obstacle is enabled.
First lets disable the obstacle:
obstacle.enabled = false
Then on the second Update() loop lets enable the agent:
agent.enabled = true
agent.destination = wherever...
I think giving it some time, at least one loop, will help to avoid the "jumping" behavior. Give it a try.
Your answer
Follow this Question
Related Questions
Unity NavMesh obstacle avoidance? 0 Answers
Trouble with Navmesh Agent and Navmesh Obstacle 0 Answers
Navmesh carving causing issues upon enabling navmesh agent component 0 Answers
Way to ignore specific navmeshobstacles for specific navmeshagent when creating path? 0 Answers
How to let a navMeshAgent detect if path is blocked by an obstacle? 1 Answer