How can I remove gimbal lock from the Third person camera?

Hey all,

So I’m currently working on a sky diving portion of my game that’s based off the Third Person project and I was wondering how to remove the gimbal lock on the camera. Right now the gimbal is fine for moving on the ground, but when free falling I want to remove the lock to allow the player to view/move without restriction. The current setup I’m using is:

// Create a camera boom (pulls in towards the player if there is a collision)
CameraBoom = PCIP.CreateDefaultSubobject<USpringArmComponent>(this, TEXT("CameraBoom"));
CameraBoom->AttachTo(RootComponent);
CameraBoom->TargetArmLength = 100.0f; // The camera follows at this distance behind the character	
CameraBoom->bUseControllerViewRotation = true; // Rotate the arm based on the controller

// Create a follow camera
FollowCamera = PCIP.CreateDefaultSubobject<UCameraComponent>(this, TEXT("FollowCamera"));
FollowCamera->AttachTo(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
FollowCamera->bUseControllerViewRotation = false; // Camera does not rotate relative to arm

The follow camera is of type UCameraComponent and when free falling I lerp the players movement in the direction of the camera so the players rotation follows the camera with a slight delay/smooth.

Is there a an easy way to do this or will I need to setup my own camera type inheriting from UCameraComponent?

Thanks in advance

To avoid gimbal lock, you use local rotations. so for example, in the blueprint attached, i’m calling ‘HandleRotation’ on tick. then input is used to control a gate adding local rotations to spring arms and meshes simultaneously.

Here is a solution I came up with that allows the use of Euler rotations with some quaternions exposed from c++. Everything is implemented in blueprints for people who don’t know any code.