Unreal Engine: Controllers and Game Modes

·3 min read·Graham Mace
Unreal Engine: Controllers and Game Modes

Following on from last week’s introduction to the Unreal editor, this week was all about controllers and game modes – how Unreal decides what the player is, where they spawn, and how input reaches the pawn.

As I’ve been following along with the course, I’ve been committing changes to the repository as I go, so you can see the state of the project at each stage of the series:

sawnoff-studios/first-project

Here are my notes from this week’s content.

Pawns, Controllers and Game Modes

  • F8 in Play In Editor detaches you from your pawn into a free spectator camera (press it again to re-possess)
  • Player Start is the actor the player spawns at; you can add one quickly via the "+" quick-add menu at the top of the editor
  • The GameMode is responsible for deciding what gets spawned: the default pawn, the controller, and other framework pieces – GameMode subclasses let you swap out behaviour per level or game type
  • A custom Spectator Pawn lets you fly the camera around freely during play

Two Input Systems

Unreal currently ships with two input systems, and you’ll encounter both in older tutorials:

  • The Legacy input system – the original
  • The Enhanced Input system – the modern replacement, and what new projects should use

Legacy Input

  • Create an InputAction, then drag from the Pressed/Released pins to bind behaviour
  • Use Print String nodes to debug what’s firing
  • Axis-type events fire every frame while held, not just once
  • Add Movement Input takes a World Direction, not a speed:
    • Feeding it a larger vector direction doesn’t make you move faster – direction and magnitude of input are separate concerns
    • Actual movement speed comes from the pawn’s movement component (e.g. Max Walk Speed)

Enhanced Input

The newer system splits things into two assets:

  • Input Action – roughly the equivalent of an action/axis mapping in the legacy system; configure the Value Type (e.g. Axis2D for mouse look)
  • Input Mapping Context – houses your Input Actions; add actions, assign keys, and attach modifiers (e.g. Negate to invert an axis)

Gotcha: if your input does nothing at first, the mapping context probably hasn’t been activated. In the pawn’s BeginPlay, get the Enhanced Input Local Player Subsystem (via the Player Controller) and call Add Mapping Context on it.

C++ setup: add “EnhancedInput” to your module dependencies in Build.cs:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput" });

Gotcha #2: mouse-look working but the camera not rotating with your pawn? On the Spring Arm, tick Use Pawn Control Rotation.


Notes on things that tripped me up

The two big walls I hit this week were both silent failures: the pawn refusing to respond to input (unbound mapping context) and mouse movement not affecting the camera (spring arm rotation). Neither throws errors – worth remembering for next time.