Skip to content

Tutorial: create and use a Motion input

This tutorial shows a complete Motion input path: create an Enhanced Input action, add it to a project-owned copy of the Motion keyboard mapping context, then consume it in Play mode.

By the end, pressing E will trigger a new IA_Interact action. You will first consume it in a project-owned character Blueprint, then route the same input to a small custom Motion component.

Use this tutorial after the Motion character already moves in PIE. If you have not reached that point yet, start with Quick start or Add Motion to a character.

Start from a working character

  1. Enable plugin content if it is hidden: Settings > Show Plugin Content.
  2. Locate B_MotionCharacter in Motion > Blueprints and duplicate it into Content/MotionTutorial.
  3. Rename the duplicate B_MotionTutorialCharacter.
  4. Duplicate B_MotionGameMode into the same project folder and rename it B_MotionTutorialGameMode.
  5. Open the duplicated GameMode and set Default Pawn Class to B_MotionTutorialCharacter.
  6. In the test map's World Settings, set GameMode Override to B_MotionTutorialGameMode.

You are starting from a project-owned copy of a character that already adds the Motion input mapping context and consumes Motion input. This preserves the shipped plugin assets while giving the new action a known working path.

The shipped character already has a working input setup. Use it as the reference before adding your own action.

Motion input setup on the shipped character

Create an input action

For this lesson, create your own interact action.

  1. Open the Content Drawer.
  2. In your project content, create a folder named MotionTutorial/Input.
  3. In that folder, create an Input Action.
  4. Name it IA_Interact.
  5. Open IA_Interact.
  6. Set Value Type to Boolean.
  7. Save the asset.

If you are modifying an existing input instead, open that input action and keep the value type that the consuming code expects. Sprint, crouch, jump, and interact-style actions should stay Boolean. If you only want to change which key triggers an existing action, change the row in the mapping context instead of creating a new input action.

Add the action to the keyboard IMC

Now add the action to a project-owned copy of the input mapping context that the demo character uses.

  1. Locate IMC_Motion_KBM in Plugins > MotionCore Content > Motion > Blueprints > Input and duplicate it into Content/MotionTutorial/Input.
  2. Rename the duplicate IMC_MotionTutorial_KBM.
  3. Open it and add a new mapping row.
  4. Set the row's action to your project IA_Interact.
  5. Set the key to E.
  6. Leave triggers and modifiers empty.
  7. Save IMC_MotionTutorial_KBM.

Open B_MotionTutorialCharacter. In its ReceiveControllerChanged flow, find the existing Add Mapping Context node and replace its mapping-context asset with IMC_MotionTutorial_KBM. Compile and save the Blueprint.

Changing IMC in the character blueprint

The same setup path is used by the Motion character's existing movement actions, so if the shipped actions work in PIE, your new action should flow through the same mapping context once added.

Consume the input in the character Blueprint

Use this first path when the action belongs directly to your character or controller.

  1. Return to B_MotionTutorialCharacter.
  2. Open the Event Graph.
  3. Right-click in the graph and search for IA_Interact.
  4. Add the Enhanced Input action event for IA_Interact.
  5. Use the Started execution pin.
  6. Add a Print String node.
  7. Set the string to Interact pressed from B_MotionTutorialCharacter.
  8. Connect Started to Print String.
  9. Compile and save B_MotionTutorialCharacter.

Use Started for one-shot actions such as interact, fire, inspect, or reload. Triggered can fire repeatedly while an action remains active.

Verify the Blueprint path

  1. Press Play.
  2. Press E.
  3. Confirm the on-screen message appears once when the key is pressed.
  4. Stop Play mode.

The important check is that E works through the same mapping context the character already uses.

Move the input into a custom Motion component

Use this path when the behavior should live in a reusable component instead of one character graph. The character continues to own the Enhanced Input binding because its input component is created during possession and can be unavailable when an actor component's BeginPlay runs.

Create a C++ component named MotionInteractComponent that inherits from UMotionComponentBase.

cpp
// MotionInteractComponent.h
#pragma once

#include "CoreMinimal.h"
#include "MotionCore/Components/MotionComponentBase.h"
#include "MotionInteractComponent.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FMotionInteractInputEvent);

UCLASS(Blueprintable, ClassGroup=(Motion), meta=(BlueprintSpawnableComponent))
class YOURGAME_API UMotionInteractComponent : public UMotionComponentBase
{
	GENERATED_BODY()

public:
	UPROPERTY(BlueprintAssignable, Category = "Motion|Input")
	FMotionInteractInputEvent OnInteractPressed;

	UFUNCTION(BlueprintCallable, Category = "Motion|Input")
	void HandleInteractInput();
};
cpp
// MotionInteractComponent.cpp
#include "MotionInteractComponent.h"

#include "Engine/Engine.h"

void UMotionInteractComponent::HandleInteractInput()
{
	OnInteractPressed.Broadcast();

	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(
			-1,
			2.0f,
			FColor::Green,
			TEXT("Interact pressed from MotionInteractComponent"));
	}
}

Replace YOURGAME_API with your game module's API macro. If this component lives in your game module, add MotionCore to that module's dependencies, then compile. The Blueprint owns the input event, so this component does not need an EnhancedInput dependency.

csharp
PublicDependencyModuleNames.Add("MotionCore");

Use the custom component

  1. Open B_MotionTutorialCharacter.
  2. Add MotionInteractComponent to the character.
  3. Drag the component from the Components panel into the Event Graph as a reference.
  4. Replace the Print String node after IA_Interact's Started pin with a call to HandleInteractInput on that component reference.
  5. Compile and save B_MotionTutorialCharacter.

The character now owns the possession-sensitive input binding, while the component owns the reusable behavior and broadcasts OnInteractPressed for any additional Blueprint listeners.

Verify the component path

  1. Press Play.
  2. Press E.
  3. Confirm the component message appears.
  4. Stop Play mode.

You now have the same input action flowing through a reusable Motion component.

What you practiced

You practiced the full input path Motion expects:

  1. Create or modify an Enhanced Input action.
  2. Add the action to an input mapping context.
  3. Keep the mapping context assigned to the local player.
  4. Consume the action directly in the character when the behavior is local to that character.
  5. Route the action from the owning character to a custom Motion component when the behavior should be reusable.
  6. Verify the new action through the already-working Motion input path.

Where to go next

Motion - Advanced First Person Character Controller