How to know if a gameobject is rotating?


I have a GameObject (a cube), and I make it rotate on X or Y axis.

I use a Quaternion.Lerp to “animate” its moves. However I’d like to wait before it has finished its rotation before asking him to rotate another time. That’s why I’d like to know how to be sure to quaternion are equals.

First I tried with the Quaternion’s == operator (as mentionned in the documentation):

if ( final_rotation == transform.rotation )  

But sometimes it returned me false even after the Lerp has finished for a long time. So I tried testing the Vector3 values:

if ( final_rotation.eulerAngles == transform.rotation.eulerAngles )

And it sometimes give me the same result : it returns me false even if Debug.Log returns me the same result.

I think it’s something in relation to float precision, but I can’t find how to deal with it.
Thank you in advance.

The problem with Slerp is it can take a really long time to finish, especially using a Time.deltaTime calculation. You are probably better off checking for a small difference in the angles:

 if((final_rotation.eulerAngles - transform.rotation.eulerAngles).sqrMagnitude < 0.1) {