示例#1
0
 private void Start()
 {
     path          = new List <TANode>();
     pathCounter   = 0;
     path          = TAPathing.SetTarget(seeker.position, target.position, grid);
     targetLastPos = target.transform.position;
 }
示例#2
0
 private void Update()
 {
     if (path != null && (path.Count > 0 && !(pathCounter >= path.Count)))
     {
         if (Vector3.Distance(seeker.position, new Vector3(path[pathCounter].position.x, seeker.position.y, path[pathCounter].position.z)) < 1.0f)
         {
             pathCounter++;
         }
         else
         {
             seeker.position = Vector3.MoveTowards(seeker.position, new Vector3(path[pathCounter].position.x, seeker.position.y, path[pathCounter].position.z), Time.deltaTime * speed);
         }
     }
     if (Vector3.Distance(target.position, targetLastPos) > detectRange)
     {
         path          = TAPathing.SetTarget(seeker.position, target.position, grid);
         targetLastPos = target.transform.position;
         pathCounter   = 0;
     }
 }