Ok, so I’m trying to get an object to rotate 180 degrees after a keystroke triggers a gravity reversal in my game (so that it’s “walking on the ceiling”, or back on the ground after a second reversal). I’ve got the gravity part worked out but I’m having trouble getting the object to rotate when the gravity shift occurs.
I’ve searched all over for a few hours now on how to Lerp between the two rotations and most answers provide something like this:
transform.rotation = Quaternion.Lerp (fromRotation, toRotation, Time.time * speed);
with fromRotation and toRotation being Transforms. But nothing explains how I define those Transforms other than to have an empty variable to drag in objects (but the unity scripting reference says they should be different objects than the one my script is attached to- which doesn’t help me at all since all three of these things (the current rotation, the destination rotation and the object this script is attached to) are all applying to the same object).
So how do I define the toRotation to simply be 180 degrees from the fromRotation/current rotation in the first place? i know Quaternions aren’t simply x/y/z but I’m not seeing how to define a rotation without making extra objects for them to look at (which I could do, I suppose, but that’s seems extraordinarily unnecessary).