Is there anyway to set control rotation with a quaternion?
I'm trying to have 6DoF with my control rotation. I keep running into gimbal lock. My world is round and the players feet should always point towards the planets center. When I try to add in the mouse input X rotation I believe it is causing it. I keep reading everywhere that keeping rotations as quaternions will eliminate this but I don't see how I can when SetControlRotation only takes a rotator.
asked Jul 05 '16 at 09:18 PM in C++ Programming
Finally!!! The solution was to set the capsule upvector rotation first using MakeFromZX. Then using the capsules AddLocalRotation (which the control rotation doesn't have) I add in the mouse X input rotation. Then finally set the control rotation using the capsule rotations. No Gimbal Lock. I had to set bUseControllerRotation (Pitch, Roll, And Yaw) to False first.
answered Jul 07 '16 at 04:19 PM
FRotators are not Euler internally. They let you modify the rotation of a character with Euler because it's intuitive as opposed to entering Quaternion values directly. You can calculate your quaternion and assign it to your rotator.
This next part I'm writing off the top of my head so there might be mistakes, but to calculate that quaternion assuming the player is standing on a sphere I would try something like the following:
If VecUp is the 'up' vector at the point on the sphere the player is standing, then:
That would put him in the correct orientation (feet on ground, head towards the sky), then to spin him in place to the desired facing:
You would keep track of what 'Yaw' or spin round his center he has at the time.
answered Jul 06 '16 at 09:34 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here