Rotations sticks at 90deg

The code that says “Using Quat” technically isn’t using a Quaternion to determine the rotation, you’re just creating a Quat after you’ve applied the rotation change to a rotator. There’s a big difference between using the Quat as a function argument and actually using it to do the math operation.

I would do it the following way using Matrices. Get the up-vector of your hinge (the axis you want the door to rotate on), rotate the front vector of the door around it, then get a rotation back from the vector. This will avoid gimbal lock completely. The following is peusdo-code but you kind of get it. I haven’t tested this btw, and there’s probably a quicker way - I just can’t think in Quats atm…



// Amount we want to rotate the door.
const float RotationAngleDegrees = DeltaRot * GetWorld()->GetDeltaSeconds();

// Axis we want to rotate the door on.
const FMatrix HingeUpMatrix = FRotationMatrix::MakeFromZ(GetHingeUpVector());

// Front vector of the door, rotated around the axis
const FVector NewDoorFrontVector = FVector::RotateAngleAxis(RotationAngleDegrees, HingeUpMatrix);

// Transform the vector to a rotator (or a quaternion, whatever you want). Use XZ to enforce orthoganility
const FRotator DoorRotation = FRotationMatrix::MakeFromXZ(NewDoorFrontVector, GetHingeUpVector()).Rotator();

// Apply Rotation