예제 #1
0
 /// <summary>
 /// Calculate a path between two points and store the resulting path.
 /// </summary>
 /// <param name="sourcePosition">
 /// The initial position of the path requested.
 /// </param>
 /// <param name="targetPosition">
 /// The final position of the path requested.
 /// </param>
 /// <param name="exclude">
 ///
 /// </param>
 /// <param name="path">
 /// The resulting path.
 /// </param>
 /// <returns>
 /// True if a either a complete or partial path is found and false otherwise.
 /// </returns>
 public static bool CalculatePath(Vector3 sourcePosition, Vector3 targetPosition, ushort exclude, XNavMeshPath path)
 {
     Vector3[] temp_corners = new Vector3[MAX_CORNER];
     path.status = DetourMgrEx.detourMgrFindPath(ref sourcePosition, ref targetPosition, temp_corners, exclude);
     if (path.status == XNavMeshPathStatus.PathComplete)
     {
         int len = temp_corners.Length;
         for (int i = 0; i < len; i++)
         {
             if (temp_corners[i] != Vector3.zero)
             {
                 path.AddCorner(temp_corners[i]);
             }
             else
             {
                 break;
             }
         }
         return(true);
     }
     return(false);
 }