Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1.     protected void UpdateFleeState()
  2.     {
  3.         //Set the target position as the player position
  4.         destPos = playerTransform.position;
  5.  
  6.         //Check the distance with the player tank
  7.         float dist = Vector3.Distance(transform.position, playerTransform.position);
  8.  
  9.         if (dist <= 200.0f && health <= 200)
  10.         {
  11.             Quaternion targetRotation = Quaternion.LookRotation(destPos - transform.position);
  12.             transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, Time.deltaTime * curRotSpeed);
  13.  
  14.             //Go Forward
  15.             transform.Translate(Vector3.forward * Time.deltaTime * curSpeed);
  16.         }
  17.         curState = FSMState.Patrol;
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement