示例#1
0
    IEnumerator UpdatePath()
    {
        // needs to change target here

        if (Time.timeSinceLevelLoad < .3f)
        {
            yield return(new WaitForSeconds(.3f));
        }
        PathReqManager.RequestPath(new PathRequest(transform.position, target.position, OnPathFound));

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

        while (true)
        {
            yield return(new WaitForSeconds(minPathUpdateTime));

            //print(((target.position - targetPosOld).sqrMagnitude) + "    " + sqrMoveThreshold);
            if ((target.position - targetPosOld).sqrMagnitude > sqrMoveThreshold)
            {
                PathReqManager.RequestPath(new PathRequest(transform.position, target.position, OnPathFound));
                targetPosOld = target.position;
            }
        }
    }
示例#2
0
 void Awake()
 {
     instance    = this;
     pathfinding = GetComponent <Pathfinding>();
 }