i want to calculate how much time does it take to complete the rotation. How do i do that

```
void Update()
{
if(Input.GetKey(KeyCode.M)
{
transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(new
Vector3(90,0,0), 50f * Time.deltaTime);
}
}
```

tyruji
July 23, 2021, 3:45pm
2
It’s actually pretty simple - all you have to do is get the angle difference and divide it by your rotation speed (50f in your case).
example code:

```
float x_diff = 90 - transform.rotation.eulerAngles.x; // you're rotating to 90
float rotation_speed = 50f;
float estimated_time = x_diff / rotation_speed; // that's it
```

Be aware this won’t work all the time, e.g. when your rotation is negative or above 90 it will break, but will still do it’s job if you have a rotation from 0 to 90 max.
Good luck!