So I have an object that can be placed on another object, the problem is that when the object is placed on another surface with a different rotation the "up" rotation of the object changes.
Its easier to explain in pictures:
Lets say the part of the tire that says "Big Wheel" is the top of the object
When that object is moved to the other side of the engine (big white object) the wheel rotates so that "BigWheel" is now facing the side:
I do not want the wheel to rotate like that, I want it to always be facing the same way on one axis.
Please note that in this part of my game the player is creating a vehicle and the wheels need to be facing the ground so that the WheelColliders work when the player runs the simulation. Also the wheel consists of two objects (the wheel and the "axel" which the wheel is parented to).
don't use euler angles (rotation XYZ in inspector) to store "up" rotation. euler angles is just a representation of Quaternion (rotation is stored in this format). not unique. so two different rotations in euler angles can be the same.
so first create a default rotation (where wheel is UP (strange sounds)) and then use transform.RotateAround(...) method to rotate around Y axis. so you can be sure wheel always be UP
for example (imagine or try that) when you rotate an object in euler angles by 90 or 270 degrees around X axis, your Y and Z rotations are rotates object around the same axis...
answered Jul 23 '12 at 06:46 PM