Advertisement
Guest User

Untitled

a guest
Jul 7th, 2021
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1. private void FixedUpdate()
  2. {
  3.     switch (state)
  4.     {
  5.         case State.Patrolling:
  6.             Patrol();
  7.             break;
  8.     }
  9. }
  10.  
  11. private void Patrol()
  12. {
  13.     if (state != State.Patrolling)
  14.         return;
  15.  
  16.     aiDestinationSetter.target = waypoints[waypointIndex];
  17.  
  18.     if (Vector2.Distance(transform.position, waypoints[waypointIndex].transform.position) <= 0.17f)
  19.         waypointIndex++;
  20.  
  21.     if (waypointIndex == waypoints.Count)
  22.         waypointIndex = 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement