I’ve come across some behaviour with applying a rotation to a transform that I don’t really understand.
What happens is: when I apply a rotation to a transform, the resulting rotation of this transform will sometimes not be the same that I applied.
e.g.:
var rotation = Random.rotation;
transform.rotation = rotation;
bool equals = transform.rotation.Equals(rotation);
I noticed that when I normalize the rotation before setting it, it is equal more often (1/10 chance of it being not equal).
My current guess is that Unity normalizes the Rotation every time it is set and with some Quaternions normalizing a normalized Quaternion will not give the same result?
What I want to achieve is to take the rotation from an object, save it and later apply this rotation to the same object again so it is exactly the same.
e.g.:
var rotation = Random.rotation;
transform.rotation = rotation;
rotation = transform.rotation;
transform.rotation = rotation;
bool equals = transform.rotation.Equals(rotation); //should be equal, but it's not
We’re developing a game with cloning and we got deterministic physics somewhat figured out, except for this rotation thing that happens sometimes.
Does anybody know what the cause of this is or how we could work around it?