コード例 #1
0
    IEnumerator UpdatePath()
    {
        yield return(new WaitForSeconds(audioStart.clip.length - 0.5f));

        PathRequesting.RequestPath(new PathRequest(transform.position, target.position, OnPathFound));

        float   sqrMoveThreshold = pathUpdateMoveThreshold * pathUpdateMoveThreshold;
        Vector3 targetPosOld     = target.position;


        while (transform.position != target.position)
        {
            yield return(new WaitForSeconds(minPathUpdateTime));

            if ((target.position - targetPosOld).sqrMagnitude > sqrMoveThreshold)
            {
                PathRequesting.RequestPath(new PathRequest(transform.position, target.position, OnPathFound));
                targetPosOld = target.position;
            }
        }
    }
コード例 #2
0
 void Awake()
 {
     instance    = this;
     pathfinding = GetComponent <Pathfinding>();
 }