Download

Better way to rotate objects..(FRotators and FQuats dont seem to work)

Hello Everyone…

I am currently working on a game similar to a space simulator. There is a lot of rotation freedom which I am in need of.

FRotator additions don’t work they give arise to Gimbal Lock problems…
I tried to solve it using using FQuats but they generate another problem…

When multiplying a FQuat having Pitch and Yaw with a rotator, a small amount of Roll gets added to the rotator which is something I absolutely don’t want to happen.

Are there any better algorithms to solve this issue?

b4c5b92d3b6213c5b5ce0050c731e10ceb0d8e6d.jpeg

I rotate around the Actor Vectors, which works perfectly for me.The only difference is that my implementation actually sets the angular velocity of an object through the physics engine, but the basic premise should be the same. What you’ll find with you’re current implementation is that the ‘small’ amount of roll turns into even more depending on what angle you’re rotating from.

For Roll for example, get the actors Forward Vector and multiply it by whatever rotation value you require. That’s you’re new local-space rotation vector. Convert that to a rotator via ‘Rotate Vector’ and you should be okay. You should also be able to use ‘Add Actor Local Rotation’ or whatever it’s called, since that deals with Quats at a lower-level in the code I believe.

Quaternion rotation should work just fine for you also, but doing rotation via Quat’s is pretty complex. I avoided it in my implementation since mine is all based on angular velocity anyway, and is basically a 6-DOF pawn on top of a spring, which also modifies the angular velocity to make it conform to the surface normal below it.