Language:
Discover
By Skill Level
By Category

UCharacterMovementComponent::SetMovementMode

Choose your OS:

Syntax

virtual void SetMovementMode
(
    EMovementMode NewMovementMode,
    uint8 NewCustomMode
)

Remarks

Change movement mode.

Parameters

Parameter

Description

NewMovementMode

The new movement mode

NewCustomMode

The new custom sub-mode, only applicable if NewMovementMode is Custom.

Example Code

MyCharacter.cpp at line 184:

void AMyCharacter::ToggleFly()  
{  
    if( GetCharacterMovement()->IsFlying() == false )  
    {  
        // If we are not flying already then set our movement mode so that we are  
        GetCharacterMovement()->SetMovementMode( MOVE_Flying );  
    }  
    else  
    {  
        // Set the new movement mode to walking  
        GetCharacterMovement()->SetMovementMode( MOVE_Walking  );  
    }  
}

References

Module

Engine

Header

Runtime/Engine/Classes/GameFramework/CharacterMovementComponent.h

Source

Runtime/Engine/Private/Components/CharacterMovementComponent.cpp