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

Implementing Possession and Unpossession Logic

Learners will master the process of dynamically linking and unlinking a controller to different pawns during active gameplay sessions.

In this lesson, you will learn how to dynamically shift a player’s focus from one physical character to another by mastering the mechanics of possession and unpossession.

The Mechanics of Possession

In Unreal Engine, your PlayerController is the "brain," while the Pawn is the "body." Usually, the game starts with a controller possessing a single pawn, but you can swap that connection during gameplay. When a controller "possesses" a pawn, it starts routing input commands (like movement or firing) directly to that specific actor.

The Unpossession Workflow

To switch characters, you must first tell the current pawn to stop receiving commands. This is done by calling UnPossess() on the PlayerController. This action severs the link between the brain and the body, leaving the current pawn idle.

Once the controller is empty, you target a new Pawn actor and call Possess(NewPawn) on the controller. This instantly re-establishes the connection, making the new pawn the active target for your inputs.

Here is a simplified example of how you might trigger this transition in your PlayerController class:

// 1. Unpossess current pawn
if (GetPawn())
{
    UnPossess();
}

// 2. Possess the new target pawn
if (NewPawnTarget)
{
    Possess(NewPawnTarget);
}

Why This Matters

This logic is essential for advanced gameplay mechanics, such as:

  • Vehicles: You unpossess your human character to enter a tank, then possess the vehicle to control its turret.
  • Strategy Games: You jump between different units on the battlefield to provide direct commands.
  • Cinematics: You may unpossess the player to take control of a camera actor to orchestrate a cutscene.

Remember, when you unpossess a pawn, it will remain in the world exactly where it was left. If you want it to behave intelligently afterward, you must ensure it has an AI Controller waiting to take over, or it will simply sit frozen in place.

Key Takeaway: Possession is a dynamic link; by calling UnPossess() followed by Possess(), you can instantly transfer player authority between any two pawns in your game world.