I used to get away using this (although not recommended) but it’s giving problems in my current project… Can anyone point me in the right direction when combining rotations as such? I’m going nuts!
Isn’t doing what you want, you might need to provide some more detail. Can you describe the context for the problem? What’s the desired behavior? And what behavior are you seeing?
(Also, when working with Euler angles, you can just access/modify the ‘eulerAngles’ field directly.)
objA is moving continuously along its z axis (objA.Translate(0,0,1)), the purpose of objB is a terrain mapper which rotates accordingly to the normal objA is on. I get the normal/surface rotation by:
// After a raycast hit
var surfaceRot : Quaternion = Quaternion.FromToRotation(Vector3.up,hitSurface.normal);
var followRot : Quaternion = surfaceRot * Quaternion.AngleAxis(objA.eulerAngles.y,Vector3.up);
for objA to adapt to the terrain. Works well BUT when objA is on a 90 degree surface (meaning objA.eulerAngles.x = 90), sometimes only the Z rotation of objB is applied, making objA’s up vector parallel to the terrain. Other times, it works. Strangely enough, when you check the orientation of objB on the Editor, it is always correct as per the terrain.
When I access eulerAngles directly, I get the same problem.
I need objA’s Y rotation free as this is controllable by the user. Been going in circles for a week!!! Any ideas or better methods?
I’m sure this problem would be straightforward to solve, but I’ll admit I still don’t fully understand what you’re wanting to do. (I might help if you were to post a screenshot showing both of the objects oriented more or less as you want them to be oriented so that we can see the desired relationship between them.)