Here are the examples of the csharp api UnityEngine.NavMesh.CalculatePath(UnityEngine.Vector3, UnityEngine.Vector3, int, UnityEngine.NavMeshPath) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
Source : AI_PatrolEditor.cs
with MIT License
from WooshiiDev
with MIT License
from WooshiiDev
private Vector3[] CalculateNavMeshPath()
{
if (points.Length == 0)
{
Debug.Log ("No path to generate!");
return null;
}
if (patrolMode == PatrolMode.RandomAreaPoint)
{
Debug.Log ("Path Generation not supported with this mode!");
return null;
}
NavMeshPath path = new NavMeshPath ();
List<Vector3> pathing = new List<Vector3> ();
//Loop all points and calculate movement path to next point
for (int i = 1; i <= points.Length; i++)
{
if (i < points.Length)
{
//Get two neighbouring points and ^^^
Vector3 previousPoint = points[i - 1].point;
Vector3 currentPoint = points[i].point;
NavMesh.CalculatePath (previousPoint, currentPoint, 1, path);
}
else
{
//Link final and first points up
NavMesh.CalculatePath (points[i - 1].point, points[0].point, 1, path);
}
//Add to list
for (int j = 0; j < path.corners.Length; j++)
pathing.Add (path.corners[j]);
}
//Store in array
return pathing.ToArray ();
}