- Home /
Unity NavMesh obstacle avoidance?
So, I calculate the path to the target. The target can move around so the path is always changing. The Object avoids obstacles like it should and everything works fine. But, when you can't calculate a path because there is no way to reach the target, weird stuff happens. So, I just say
if (m_Agent.pathPending)
{
transform.position = Vector3.MoveTowards(transform.position, m_Target.transform.position, m_MoveSpeed * Time.deltaTime);
transform.LookAt(new Vector3(m_Target.transform.position.x, transform.position.y, m_Target.transform.position.z));
}
But this doesn't avoid obstacles.
So any ideas?
In my experience with Navmesh, it doesn't like the agents to be manually moved.
Have you tried setting Nav$$anonymous$$eshAgent.autoRepath to true if it isn't already?
Why can't you calculate a path? Are there dynamic obstacles in the way?
Ya I tried that it didn't work. Imagine there is a square frame and you are inside it. I can't reach you so how do I still avoid some obstacles to get to the frame but when I get to the frame, I want to just keep moving towards the target. Like a zombie that doesn't understand how to get to the target.
Your answer
Follow this Question
Related Questions
NavmeshAgent and NavmeshObstacle and Bake don't work with AICar 0 Answers
Trouble with Navmesh Agent and Navmesh Obstacle 0 Answers
Toggling NavMeshAgent and NavMeshObstacle 2 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