Quaternion.Euler is persisting into other values

I have some basic code that should, in theory, rotate one transform to one value, and the other to another value.

    transform1.rotation = Quaternion.Euler(0f, someValue, 0f);
    transform2.rotation = Quaternion.Euler(0f, 0f, 0f);

This should be working. However, what ends up happening, is that it acts like:

    transform1.rotation = Quaternion.Euler(0f, someValue, 0f);
    transform2.rotation = Quaternion.Euler(0f, -someValue, 0f);

It seems that whichever rotation comes first leaks into the second one in this manner. If I reverse the order and set transform2’s rotation first, then transform1 gets its values set to the negative of transform2’s. I don’t understand why this is happening, but it is a big issue.

Hello Lionmeow,

Rotations can be quite tricky. May I look at some broader code of yours? How do you plan to rotate one transform to another? - Meaning, are you changing ‘someValue’ over time?

Here is an article that may help: Quaternion.Lerp

Lerp is really useful because it automatically rotates objects for you over time, at whatever speed you need.

Broader code wouldn’t help me to solve this issue, considering it happens regardless of what else I put in the method. Even if I change someValue to an explicit value, e.g., do this:

 transform1.rotation = Quaternion.Euler(0f, 4f, 0f);
 transform2.rotation = Quaternion.Euler(0f, 0f, 0f);

It still ends up acting like:

 transform1.rotation = Quaternion.Euler(0f, 4f, 0f);
 transform2.rotation = Quaternion.Euler(0f, -4f, 0f);

So I’m really confused. There literally aren’t any other scripts in the project at this point in time, so it can’t be another script setting transform2’s rotation.

Hello, @Lionmeow,

See if the transform1 has the same gameObject of the transform2, please.