I’d like to gradually flip my entity upright. I’m hearing that I need to get the current orientation and the up orientation and multiply them, then scale it and apply an angular velocity.
Here’s where the fact that I never got my head around quaternions is a problem.
Given a desired target heading (I was thinking up, but actually away from camera may be the way I go) and an entity moving in a given direction, as a result of collisions etc, how do I apply a force to smoothly rotate the object toward the target heading?
I’m afraid I don’t have time to do an example. Ultimately it comes down to working out the difference of the current rotation of the object is to the target rotation and applying a torque force by said difference and then apply a damping force as it gets closer to the target rotation.
It gets tricky as you have to tweak a whole bunch of numbers to get the right effect.
You can use rotation velocity instead of torque if you want finer control. You just have to deal with the edge case of what happens when you overshoot the target rotation.
Yes, that’s what I figured. It’s the math for that that I don’t currently have worked out - Figure it’s some sort of quaternion deal (although I don’t care if the rotation looks clumsy).
Is it just a cross product or something trivial?
I was thinking of using a (few) dot products between two orientation vectors. Eg, assuming you want it upright, the world up and the entity’s local up vector.