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; } } }
void Awake() { instance = this; pathfinding = GetComponent <Pathfinding3D>(); }