How do I check MovementMode from C++?

If I wanted to check if the player character is swimming, how should I do this in C++?

I know in Blueprints, it’s CharacterMovement > MovementType > Equals(enum) > Branch Node.

How would I achieve the same thing inside an if statement for C++?

Almost exactly the same.


if(GetCharacterMovement()->MovementMode == EMovementMode::MOVE_Swimming))

You can reference the character movement component using


From there, you can either use the EMovementMode Enum, or the bool vars, the same way you would in BP’s.

void AMyCharacter::GetCharacterState()
	// option 1: use the MovemenmtMode enum
	if (GetCharacterMovement()->MovementMode == EMovementMode::MOVE_Swimming)
		// is swimming

	// option 2: reference the bool vars
    if (GetCharacterMovement()->IsSwimming())
		// player is swimming