Here is a short breakdown on how to achieve 6 degrees of freedom in #UE4 without the need for quaternions or C++

The video highlights rotation in any direction without hitting gimbal lock.

Breakdown in the thread below⬇️ (1/7)
#gamedev #UE4Study
So firstly, if you have no idea what gimbal lock is, a quick google of that would help you better understand why/what is going on here.

Now by default, we control the rotation of our pawns in UE4 using Add Controller Pitch and Yaw Input (2/7)
For traditional horizontal based games we usually need only Pitch and Yaw, Roll is never used, and these nodes influence the control rotation in the Player Controller.

This Control Rotation is used to, among other things, control your camera or spring arm (3/7)
And because Control Rotation is calculated in Euler angles, you get gimbal lock.

Now here is the solution: don't use Control Rotation :)
Let the camera/spring arm be parented to the Capsule or mesh or even a scene component, and rotate that
(4/7)
Now, on the camera parent, you would want to Add rotation based on your input, not set it.

Unreal solves gimbal lock behind the scenes for many things, and one of these things is Adding Local Rotation.

So if we now use Add Actor Local Rotation, we get 6DOF camera (5/7)
Here comes the fun part, figuring out movement and controls.

I found it intuitive to add roll only when holding MMB, but I also have regular Q and E buttons for roll.

I am still using the CMC, just set to flying mode, for movement, everything is relative to the rotation (6/7)
That about sums it up, 🧮
the key was to remove the camera<->control rotation relation.

I needed CMC for replication, but this should work with any pawn/movement comp.

If you are using this for production, it might be worth considering fixing the control rotation in C++ (7/7)
You can follow @MrTapa.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.