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

Orchestrating Gameplay Flow with Controller Possession

You will learn how the GameMode triggers the possession process, linking a PlayerController to a Pawn to initiate active gameplay for a user.

In this lesson, you will learn how the GameMode acts as the director of your game by triggering the Possess process, which bridges the gap between a player's input and a physical body in the world.

The Role of Possession

Think of a PlayerController as the "brain" or the user's soul, and the Pawn as the physical body currently residing in the game level. By themselves, they are disconnected. Possession is the vital moment where the GameMode takes these two separate objects and links them together so that when you press a key on your keyboard, the Pawn reacts.

How the GameMode Orchestrates the Flow

When a player joins a match, the GameMode is responsible for deciding which Pawn to spawn and which PlayerController will take control of it. This usually happens in the RestartPlayer function. The flow typically looks like this:

  1. Spawn: The GameMode spawns a Pawn at a PlayerStart location.
  2. Assign: The GameMode identifies the PlayerController that is ready to play.
  3. Possess: The GameMode calls the Possess() function on the PlayerController, passing in the newly spawned Pawn.

You can see this connection happening in code:

// Inside your GameMode's RestartPlayer function
void AMyGameMode::RestartPlayer(AController* NewPlayer)
{
    // 1. Spawn the Pawn class defined in the GameMode
    APawn* MyPawn = GetWorld()->SpawnActor<APawn>(DefaultPawnClass, StartSpot);
    
    // 2. Tell the Controller to take over the Pawn
    NewPlayer->Possess(MyPawn);
}

Once Possess() is called, the PlayerController gains ownership of the Pawn. The controller then starts routing input—like moving the mouse or pressing "Jump"—directly into the logic contained within that specific Pawn. If the Pawn is destroyed, the GameMode can trigger the possession process again for a respawn, ensuring the gameplay flow remains uninterrupted.

Key Takeaway: Possession is the crucial handshake where the GameMode assigns a physical Pawn to a PlayerController, enabling the bridge between user input and in-game character movement.