0
\$\begingroup\$

I have the following code that gets run when a game object collides with a trigger. When the object is created, it is created within an initial trigger which fires the SetNextWaypoint code below and it works fine.

protected NavMeshPath path;
protected NavMeshAgent agent = null;

void Start () {
    path = new NavMeshPath();
    agent = GetComponent<NavMeshAgent>();
}

public void SetNextWaypoint(Vector3 location){
    agent.ResetPath();
    path.ClearCorners();
    agent.CalculatePath(nextWayPoint, path);
    agent.SetPath(path);
}

Once the agent enters a new waypoint (it may not have reached its destination yet) SetNextWaypoint is called again and when it does the agent just stops where it is, and doesn't move anywhere.

\$\endgroup\$
0
\$\begingroup\$

I figured it out! The issues was that my next waypoint was positioned too far above the NavMesh. But for some reason path.status was still returning PathComplete.

Moving the Waypoint closer to the navmesh allowed the object to go to the next Waypoint instead of just stopping.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.