I have two empty game objects (with different parents) at different positions and with different rotations. I want to align them such that the second game object is placed in the same position as the first game object and with its z axis (i.e. the editor blue arrow) facing in the complete opposite direction to the first game objects z axis. The second game objects original z rotation should, however, be retained.
I tried doing this by:
- Storing the second game objects local z rotation
- Setting the second game objects position/rotation to the same as the
first game object
- Rotating the second game objects 180 degrees on the x axis so the “blue
arrows” of the objects are facing in
- Finally I set the second game objects local z rotation back to it’s
previous z rotation.
The problem is this doesn’t work as i’d expect, the rotations are often wrong. The only reason I can think of is because of the way euler angles work where you can have several different euler values for one quaternion (so resetting the second game objects local euler to its previous value won’t work).
Does anyone know how I might solve this problem with quaternions?