Strange physics rotation for player controlled vehicle when facing a certain direction

Hi all,

I’ve been trying to figure out what’s wrong with this code. I made some code for a physics-based flying vehicle, but for some reason when the vehicle is facing a certain direction, it rolls upside down and starts behaving weirdly. I think perhaps I’ve got some math wrong… Anyone able to figure out what it might be? Here’s the code and a video of the problem.

void UHoverMovementComponent::TorqueToTargetRotation()
{
	const FRotator DeltaRotation = UKismetMathLibrary::NormalizedDeltaRotator(TargetRotation, CurrentRotation);
	const FVector CurrentTorque = PrimitiveComponent->GetPhysicsAngularVelocityInDegrees();
	GEngine->AddOnScreenDebugMessage(-1, .1, FColor::Cyan, TargetRotation.ToString());
	PrimitiveComponent->AddTorqueInDegrees((FVector(DeltaRotation.Roll, DeltaRotation.Pitch, DeltaRotation.Yaw) - (CurrentTorque * TorqueDamping)) * TorqueForce, NAME_None, true);
}