🏃‍♂️Movement Modes

Documentation regarding character movement in the ODK

The ODK seperates different types of movements into different conceptual movement modes. Walking, grinding and gliding are examples of different movement modes available in the base ODK.

Movement modes are controlled via a component on the BP_ODK_PlayerCharacterBase render target. By default, this component is BPC_ODK_MovementComponent, however this can be overriden on BP_ODK_PlayerCharacterBase by setting the MovementComponentClass property.

The BPC_ODK_MovementComponent controls which movement mode should be active at a given time. A mapping is defined on this component between a "movement mode id" and a movement mode component class. This allows for easy overriding and addition of movement mode behaivours.

A description of other useful properties: - Initial Movement Mode - The movement mode your character will start in. - Default Movement Mode - The movement mode that your character can default to after leaving a movement mode. - Startup Movement Modes - Movement modes that will be initialized at the start of the game rather than created dynamically when first requested. This has very niche uses.

Each movement mode is wrapped up in it's own component that derives from BPC_ODK_MovementModeComponentBase.

BPC_ODK_MovementModeComponentBase components as a good general rule should manage these areas:

  • Input - Handling enhanced input actions that modify the behaivour within a movement mode.

  • Character movement - The logic that actually moves the character.

  • Movement mode validity - Whether it is appropriate to be able to enter the movement mode. This is comunicated through the CanEnterToMovementMode function.

  • Ending the movement mode - Ensuring the movement mode is ended when appropriate.

GlidingMovementMode Example

We will now consider the BPC_ODK_GrindingMovementMode as an example.

Here we can see how input is processed in the grinding movement mode. The only valid input action on a grinding rail is "Jump". First, we override the BPC_ODK_MovementModeComponentBase base function AddInputBindings. Inside this function we can call AddInputAction for each input we want to process. We can bind to the IA_ODK_Jump input action listening to the "Triggered" event and setup our callback. Inside the callback we perform the appropriate logic. In this case stopping the grinding and making the character jump. You can see that the callback has a "Value" paramater that is sometimes useful when processing input. You should use the value corresponding to the "Value Type" on the given input action.

Adding a binding for an input action
Processing an input action to make the character jump. The "Value" param is not used but is show here for demonstration.

Ending the movement mode can be done by simply requesting a new movement mode. Inside the BPC_ODK_GrindingMovementMode StopGrinding function, TrySetDefaultMovementMode is called on the ODK movement component. We could transition to any movement mode we liked at this point but recommend going back to a the default movement mode.

Last updated