How can I prevent a character from turning when in the air

I’ve been playing with the side scroller template to see how I can change it. I want to keep the character from turning when it is in the air(without sacrificing air control). I’ve seen other people answer questions like this before, but those were all for blueprints. I’d appreciate it if someone would let me know how to do it in C++.

If anyone was wondering, here’s a something I tried before posting this. I put it in ASideScrollerExampleCharacter::ASideScrollerExampleCharacter() and nothing happened. Maybe someone could explain why this is.

while (GetCharacterMovement()->MovementMode == EMovementMode::MOVE_Falling || 
GetCharacterMovement()->MovementMode == EMovementMode::MOVE_Flying)
    {
	    GetCharacterMovement()->bOrientRotationToMovement = false;
	    GetCharacterMovement()->RotationRate = FRotator(0.0f, 0.0f, 0.0f);
    }

Have you tried setting the air control variable to 0. If the velocity can’t change it has nothing to align to

It works, but I’d prefer a solution where the player still has control over the character’s movement (without using momentum).

I decided to modify my previous method a bit and put it in ASideScrollerExampleCharacter::Tick(float DeltaTime). It worked out how I wanted it to.

if ((GetCharacterMovement()->MovementMode == EMovementMode::MOVE_Falling) || (GetCharacterMovement()- 
>MovementMode == EMovementMode::MOVE_Flying) && (!GetCharacterMovement()->MovementMode == 
EMovementMode::MOVE_Walking))
    {
	    GetCharacterMovement()->bOrientRotationToMovement = false;
	    GetCharacterMovement()->RotationRate = FRotator(0.0f, 0.0f, 0.0f);
    }
    else
    {
	    GetCharacterMovement()->bOrientRotationToMovement = true;
	    GetCharacterMovement()->RotationRate = FRotator(0.0f, 5000.0f, 0.0f);
    }