- Home /
Question by
thegrandmaster97 · Feb 20, 2021 at 03:03 PM ·
ainavmeshnavmeshagentpathfinding
How can i modify the navMesh path?
I need a way to change the navMesh path once it has been calculated in order to add a new corner.
So far what i did is: i tried to recreate the corners array, but with an extra empty spot at the end. I placed the position that i need there and now i need to give this new path to my NavMesh. How can i do that? I can see that Path.corners is read only, so how would i go about making this change?
NavMeshPath path = new NavMeshPath();
agent.CalculatePath(unitGhost.transform.position, path);
//recreates the corners array with an extra space
Vector3[] corners = new Vector3 [path.corners.Length+1];
for(int i=0; i< path.corners.Length; i++)
{
corners[i] = path.corners[i];
}
//this line adds the extra corner
corners[corners.Length-1] = unitGhost.GetComponent<BluePrintScript>().directionNode.position;
agent.SetPath(path);
Comment
Your answer
Follow this Question
Related Questions
How to build a custom shape NavMesh Area 1 Answer
NavMeshAgent doesn't face to it's destination in close distance! 1 Answer
NavMesh Agent not updating (Setting) new path 1 Answer
Connecting two navmeshes without "Speedboost" 0 Answers
Modify NavMeshPath for Tactical FPS (slicing the pie/sweeping maneuver) 0 Answers