Exemple #1
0
    /*public void OnEnable () {
     *      //AstarPath.OnGraphsUpdated += CheckPathValidity;
     * }
     *
     * public void OnDisable () {
     *      //AstarPath.OnGraphsUpdated -= CheckPathValidity;
     * }*/

    /*public void CheckPathValidity (AstarPath active) {
     *
     *      /*if (!recalcOnGraphChange) {
     *              return;
     *      }
     *
     *
     *
     *      //Debug.Log ("Checking Path Validity");
     *      //Debug.Break ();
     *      if (lastCompletedPath != null && !lastCompletedPath.error) {
     *              //Debug.Log ("Checking Path Validity");
     *              StartPath (transform.position,lastCompletedPath.endPoint);
     *
     *              /*if (!lastCompletedPath.path[0].IsWalkable (lastCompletedPath)) {
     *                      StartPath (transform.position,lastCompletedPath.endPoint);
     *                      return;
     *              }
     *
     *              for (int i=0;i<lastCompletedPath.path.Length-1;i++) {
     *
     *                      if (!lastCompletedPath.path[i].ContainsConnection (lastCompletedPath.path[i+1],lastCompletedPath)) {
     *                              StartPath (transform.position,lastCompletedPath.endPoint);
     *                              return;
     *                      }
     *                      Debug.DrawLine (lastCompletedPath.path[i].position,lastCompletedPath.path[i+1].position,Color.cyan);
     *              }*
     *      }*
     * }*/

    //The frame the last call was made from this Seeker
    //private int lastPathCall = -1000;

    /** Returns a new path instance. The path will be taken from the path pool if path recycling is turned on.\n
     * This path can be sent to #StartPath(Path,OnPathDelegate) with no change, but if no change is required #StartPath(Vector3,Vector3,OnPathDelegate) does just that.
     * \code Seeker seeker = GetComponent (typeof(Seeker)) as Seeker;
     * Path p = seeker.GetNewPath (transform.position, transform.position+transform.forward*100);
     * p.nnConstraint = NNConstraint.Default; \endcode */
    public Path GetNewPath(Vector3 start, Vector3 end)
    {
        //Get a path from the Path Pool - If path recycling is off or if there are no paths in the pool, a new path will be created
        Path p = AstarPath.GetFromPathPool();

        //Reset the path with new start and end points
        p.Reset(start, end, null);
        return(p);
    }