Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void UpdateFleeState()
- {
- //Set the target position as the player position
- destPos = playerTransform.position;
- //Check the distance with the player tank
- float dist = Vector3.Distance(transform.position, playerTransform.position);
- if (dist <= 200.0f && health <= 200)
- {
- //Rotate to the target point
- /* Vector3 rot = playerTransform.rotation.eulerAngles;
- rot = new Vector3(rot.x, rot.y + 180, rot.z);
- transform.rotation = Quaternion.Euler(rot);*/
- Quaternion targetRotation = Quaternion.LookRotation(destPos - transform.position);
- transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, Time.deltaTime * curRotSpeed);
- //Go Forward
- transform.Translate(Vector3.forward * Time.deltaTime * curSpeed);
- }
- curState = FSMState.Patrol;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement