Question by
pre-end · Apr 08, 2016 at 09:43 AM ·
rotationeuler angles
How to add a delay to an object that rotates to face a target ?
I am currently using this script to make an enemy face the player :
public float speed;
private Transform player;
void Start()
{
player = GameObject.FindWithTag ("Shooter").transform;
}
void Update ()
{
float z = Mathf.Atan2 ((player.transform.position.y - transform.position.y), (player.transform.position.x - transform.position.x)) * Mathf.Rad2Deg -90 ;
transform.eulerAngles = new Vector3 (0, 0, z);
}
How can I slow down this rotation ? The enemy should take a small amount of time to face the player.
Comment
Your answer
Follow this Question
Related Questions
Rotation Question 1 Answer
Why does this quaternion euler not compute? 0 Answers
How to calculate correct angles for PID? 0 Answers
How to clamp rotation, following Unity's quaternion rules 1 Answer