Course contentsShow
← Unreal Engine Game Development
Lesson 90 of 8802. The Gameplay FrameworkFree lesson

Implementing Character Movement with the Pawn Class

You will build a responsive Pawn class capable of processing movement commands and interacting with the physics engine within the game world.

In this lesson, you will learn how to translate player input into physical motion by building a responsive Pawn class that interacts directly with the Unreal physics engine.

The Role of the Pawn

While a Character class comes pre-packaged with a dedicated CharacterMovementComponent, the Pawn class is a blank slate. This gives you total control over how your object moves. To make a Pawn move, we don't just set its position—we apply forces or velocities that the physics engine interprets to move the actor through the world while respecting collisions.

Translating Input to Movement

To move a Pawn, we typically follow a three-step cycle:

  1. Input Binding: The PlayerController sends movement commands (from your keyboard or gamepad) to the Pawn.
  2. Velocity Application: We take those input vectors and apply them to the Pawn's RootComponent.
  3. Physics Integration: The physics engine handles the actual displacement, ensuring your Pawn doesn't fly through walls.

For a basic physical Pawn, you can use the AddMovementInput function, which is the standard way to feed directional intent into the engine.

void AMyPawn::MoveForward(float AxisValue)
{
    // Calculate the direction the Pawn is currently facing
    FVector Direction = GetActorForwardVector();
    
    // Pass the direction and scale to the movement system
    AddMovementInput(Direction, AxisValue);
}

Creating a Physical Connection

For the Pawn to actually "push" against the world, your root component needs to be a UPrimitiveComponent (like a UStaticMeshComponent or USphereComponent) with "Simulate Physics" enabled. When you call AddMovementInput, the engine internally calculates the desired velocity. If your Pawn has physics enabled, it will use that velocity to apply forces, allowing your object to roll, slide, or collide with the environment naturally.

If you don’t enable physics, the Pawn will move purely via kinematic interpolation. By choosing to implement it yourself in the Pawn class, you can create unique movement types—like a floating spaceship or a rolling sphere—that wouldn't fit the rigid structure of the standard Character class.

Key Takeaway: The Pawn class puts you in the driver’s seat of the physics engine, using AddMovementInput to translate abstract player commands into tangible, collision-aware motion.