Skip to content

Move

Overview

  • Moves a Pawn/Character, based on the 2D input values.
  • By default, it's connected to the IA_Move input.
  • Handles Triggered and Ongoing events.
  • Supports blocking the movement, via the presence of Gameplay Tags.

Handling Twin Stick/Top-Down Movement

For a top-down perspective, we need to configure our owning Pawn/Character with a global Forward Reference.

To do so:

  1. Add an Arrow Component to your pawn or character, under the root component;
  2. Configure it to use an absolute (world) rotation;
  3. Add the tag InputForwardReference to it.
Tag Source

If you are wondering, this Tag is defined in the UNinjaInputManagerComponent, and it will use it to provide "forward" and "right" references to any Handler.

// .h
/** World forward reference for a top-down character. */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess))
TObjectPtr<UArrowComponent> ForwardReference;

// .cpp
ForwardReference = CreateDefaultSubobject<UArrowComponent>(TEXT("ForwardReference"));
ForwardReference->ComponentTags.Add(UNinjaInputManagerComponent::ForwardReferenceTag);
ForwardReference->SetUsingAbsoluteRotation(true);
ForwardReference->SetWorldRotation(FRotator::ZeroRotator);
ForwardReference->SetArrowColor(FLinearColor::Green);
ForwardReference->SetupAttachment(GetRootComponent());

Forward Reference

Replicated Movement

It's common that replicating movement will require using a different "Add Input" function, other than the one available in the core Unreal Engine Game Framework.

For those cases, you can implement the IReplicatedMovementInterface in your Pawn or Character, and perform any logic/routing required to store and replicate the input values.

In this case, instead of using the basic MoveHandler, use the ReplicatedMoveHandler or Character: Move (Replicated), instead. This alternative handler routes the input to the interface implementation, instead of the default AddMovementInput functions from the APawn class.