Advertisement
Guest User

WoA AI Travel

a guest
Jun 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1.     public void MoveToNextIndex()
  2.     {
  3.        
  4.  
  5.         if (currentRouteIndex != -1 && this.transform.position != currentRoute.routePoints[currentRouteIndex].position)
  6.         {
  7.             moveTowardsVector = currentRoute.routePoints[currentRouteIndex].position - this.transform.position;
  8.             normalizedVector = moveTowardsVector.normalized;
  9.  
  10.             //Move to next position
  11.             if (Vector2.Distance(currentRoute.routePoints[currentRouteIndex].position, this.transform.position) > .1f)
  12.             {
  13.                 myStateMachine.myState = AI_StateMachine.States.walking;
  14.                 myController.Walk(normalizedVector.x, normalizedVector.y);
  15.                 print(moveTowardsVector);
  16.             }
  17.             else if(Vector2.Distance(currentRoute.routePoints[currentRouteIndex].position, this.transform.position) <= .1f)
  18.             {
  19.                 myStateMachine.myState = AI_StateMachine.States.idle;
  20.                 myController.Walk(0, 0);
  21.                 SetNextWaypoint();
  22.             }
  23.         }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement