Пример #1
0
    IEnumerator UpdatePath()
    {
        if (Time.timeSinceLevelLoad < .3f)
        {
            yield return(new WaitForSeconds(.3f));
        }
        PathRequestManager3D.RequestPath(new PathRequest3D(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)
            {
                PathRequestManager3D.RequestPath(new PathRequest3D(transform.position, target.position, OnPathFound));
                targetPosOld = target.position;
            }
        }
    }
Пример #2
0
 void Awake()
 {
     instance    = this;
     pathfinding = GetComponent <Pathfinding3D>();
 }