Overview
PawnSwap is built from three components and a function library:
- Pawn Swap Manager (UPawnSwapManagerComponent) on the PlayerController: switching, roster, entering/exiting seats, interaction, spectating, input and save data.
- Pawn Swap Seat (UPawnSwapSeatComponent) on a vehicle or mount: one per seat, with entry/exit points, occupant handling and access rules. Occupancy replicates.
- Pawn Swap Profile (UPawnSwapPawnComponent), optional, on any pawn: roster tag, team, auto registration, interaction switching and per-pawn overrides (blend, controller policy, input).
- PawnSwap Library (UPawnSwapLibrary): seats of a vehicle, occupants, team lookups, capsule tests.
The 15 features:
- Swap manager that possesses another pawn on request.
- Smooth view-target blend on every switch (time, function, exponent, lock outgoing).
- Roster of switchable pawns: next / previous / index / tag.
- Seat component with entry and exit points.
- Multiple seats per vehicle: driver / passenger, occupancy, possess the vehicle from the driver seat.
- Exit location validation with capsule tests and a fallback search.
- Controller policy for the pawn left behind.
- Seated occupant handling: attach, hide, collision, movement, restore.
- Interaction query for "Press E to enter" prompts.
- Seat locking and access rules.
- Events for switches, seats and denials (with a reason enum).
- Multiplayer: Server RPCs and replicated occupancy with RepNotify.
- Spectate mode without possessing.
- Input mode per pawn and a Setup Input event.
- Save / restore of roster and seat occupancy.
Requirements
| Requirement | Details |
|---|---|
| Unreal Engine | 4.27 and 5.8 |
| Module | PawnSwap (Runtime) |
| Dependencies | None (engine modules only; no other plugins are enabled) |
| Pawns | Any APawn; characters get capsule-accurate exits and movement handling |
| Platforms | Win64 and Mac (the module lists these platforms in the plugin descriptor). The code is platform-independent engine C++ with no OS-specific calls. |
| Network Replicated | Yes. Vehicles carrying seats must replicate (Replicates on). |
Installation
- Install PawnSwap from Fab into your engine, or copy the
PawnSwapfolder into your project'sPluginsfolder. - Enable PawnSwap in Edit > Plugins and restart the editor.
- C++ only: add
PublicDependencyModuleNames.Add("PawnSwap");to yourBuild.cs.
Quick start
- Open your PlayerController Blueprint and add a Pawn Swap Manager component.
- Place two characters in the level. On the second one add a Pawn Swap Profile and tick Auto Register (player index 0). The first pawn you possess is registered automatically (Register Initial Pawn).
- In the PlayerController, bind a key (Tab) to Switch To Next. Play: Tab blends the camera to the other character and gives you control.
- Open a vehicle Blueprint (any pawn, for example a wheeled vehicle), make sure Replicates is on, add a Pawn Swap Seat under the body where the driver sits. Keep Seat Role on Driver. Add a scene component
DoorLeftbeside the door and add an Entry Point with Component =DoorLeft. - Bind a key (E) to Interact on the manager. Walk to the door and press E: the character sits in the seat and you drive the vehicle. Press E again to get out at the door (or the nearest free spot).
1. Swap manager
Component UPawnSwapManagerComponent — displayed as Pawn Swap Manager. Add it to the PlayerController (an AIController also works for server-side switching without camera or input). It replicates; every request made on a client is sent to the server.
| Node | Type | Description |
|---|---|---|
| Switch To Pawn (New Pawn) | call | Possesses New Pawn with the switch blend. If New Pawn sits in a driver seat and drives its vehicle, the vehicle is taken (driving resumes). |
| Get Controlled Pawn | pure | The possessed pawn (a vehicle while driving). |
| Get Character Pawn | pure | The player's own pawn: the seated driver while driving, otherwise the controlled pawn. |
| Get Owner Controller | pure | The controller the manager is attached to. |
| Property | Default | Description |
|---|---|---|
| Switch Cooldown | 0.2 | Minimum seconds between switches (refused with Cooldown). |
| Require Roster | On | Switch To Pawn only accepts roster pawns and pawns whose profile has Switchable By Interaction (refused with Not In Roster). Keeps clients from taking arbitrary pawns. |
| Return To Occupant On Vehicle Loss | On | When the vehicle you drive is destroyed, you get the driver pawn back. |
A switch is refused when the target is invalid, already controlled, controlled by another player, not allowed by the roster rule, or requested during the cooldown; see Events.
2. Camera blend
struct FPawnSwapBlendSettings — used by Switch Blend (switching), Seat Blend (entering a driver seat / leaving it) and Spectate Blend.
| Field | Default | Description |
|---|---|---|
| Blend Time | 0.5 (Seat Blend 0.35, Spectate Blend 0.6) | Seconds. 0 cuts instantly. |
| Blend Function | Ease In Out | Linear, Cubic, Ease In, Ease Out, Ease In Out (engine view-target blend functions). |
| Blend Exp | 2 | Exponent of the Ease functions. |
| Lock Outgoing | On | Freezes the outgoing camera at its last frame while blending, so the blend starts exactly where the view was. |
Manage Camera (default on) holds the PlayerController's Auto Manage Active Camera Target during the possession so the engine does not cut the view, then restores it and starts the blend. On a remote client the hold and the blend are sent on the controller's reliable channel in order. A Pawn Swap Profile can override the blend for switches to its pawn (Override Blend).
3. Roster
The roster is the ordered list of pawns a player can switch between. It is kept on the server and replicated to the owning client.
| Node | Type | Description |
|---|---|---|
| Register Pawn / Unregister Pawn / Clear Roster | call server | Edits the roster (authority only). |
| Switch To Next / Switch To Previous | call | Cycles from the current pawn. |
| Switch To Index (Index) | call | Roster position, 0-based. |
| Switch To Tag (Tag) | call | First pawn whose profile Roster Tag or actor tag matches. |
| Get Roster / Get Roster Count / Get Active Roster Index / Is In Roster / Find Roster Pawn By Tag | pure | Queries (work on the owning client too). |
| Property | Default | Description |
|---|---|---|
| Register Initial Pawn | On | The first pawn the controller possesses joins the roster. |
| Wrap Roster | On | Next after the last goes to the first. |
| Skip Controlled By Others | On | Next / Previous skip pawns another player controls. |
Pawns can also register themselves with a Pawn Swap Profile (Auto Register, Auto Register Player Index; -1 = every player). Destroyed pawns are removed automatically.
4. Seats & points
Component UPawnSwapSeatComponent — displayed as Pawn Swap Seat. A scene component: its transform is where the occupant sits. The vehicle actor must replicate.
struct FPawnSwapSeatPoint — an entry or exit point: Component (name of a scene component of the vehicle, None = the seat itself) plus an Offset transform relative to it. The offset rotation sets the facing after an exit.
| Property | Default | Description |
|---|---|---|
| Display Name | Seat | Name for UI. |
| Entry Points | empty | Where the seat can be entered from. Empty = the seat location. |
| Exit Points | empty | Preferred exit locations in order. Empty = the entry points. |
| Max Enter Distance | 300 | Maximum distance from the pawn to the nearest entry point (0 = no limit). Refused with Out Of Range. |
| Interaction Prompt / Exit Prompt | Enter / Exit | Texts returned by interaction queries. |
Point helpers: Get Point Transform, Get Entry Transforms, Get Exit Transforms, Get Nearest Entry Location. Manager nodes: Enter Seat (Seat), Exit Seat, Get Current Seat, Is Seated.
5. Multi-seat vehicles
Add one Pawn Swap Seat per seat. Seats of the same actor form the vehicle.
| Property | Default | Description |
|---|---|---|
| Seat Role | Driver | Driver or Passenger. |
| Possess Vehicle On Enter | On | Driver seat of a pawn vehicle: the player possesses the vehicle when entering (with Seat Blend) and gets the occupant back when leaving. Passengers keep controlling their own (seated) pawn. |
| Priority | 0 | Lower values are offered first by Enter Vehicle and Get Free Seat. |
| Node | Type | Description |
|---|---|---|
| Enter Vehicle (Vehicle, Prefer Driver) | call manager | Enters the best free seat (driver first when Prefer Driver, then by Priority). |
| Change Seat (New Seat) | call manager | Moves to another seat of the same vehicle (no exit check). Moving to the driver seat takes the vehicle, moving away from it gives the occupant back. |
| Get Occupant / Is Occupied / Is Occupant Possessing Vehicle | pure seat | Occupancy (replicated). |
| Get Vehicle / Get Vehicle Pawn / Get Sibling Seats | pure seat | The owning actor and its other seats. |
| Seat Pawn / Unseat Pawn / Vacate Seat | call seat, server | Seat or unseat any pawn directly (AI passengers, cutscenes). These do not change possession; players should use the manager. |
6. Exit validation
Find Exit Transform (For Pawn) is used by every exit. It uses the pawn's capsule (character capsule, capsule root, collision cylinder, else the defaults) and tries, in order:
- Each exit point (or entry point): snapped to the ground below, tested with a capsule overlap and a line of sight from the seat (the vehicle itself is ignored for the sight test).
- Fallback rings around the vehicle bounds, starting on the side of the seat and alternating left/right.
- The roof of the vehicle.
If nothing is free the exit is refused with Exit Blocked and the occupant stays seated. struct FPawnSwapExitSettings (seat property Exit Settings):
| Field | Default | Description |
|---|---|---|
| Overlap Channel | Pawn | Channel of the capsule test. |
| Trace Channel | Visibility | Channel of the ground and sight traces. |
| Snap To Ground / Max Ground Distance | On / 250 | Moves each candidate onto the ground below it. |
| Require Ground | On | Rejects candidates without ground (cliffs, water edges). |
| Require Line Of Sight | On | Rejects candidates behind walls. |
| Use Fallback Search | On | Search rings when every point is blocked. |
| Fallback Steps / Fallback Rings / Ring Spacing | 12 / 2 / 60 | Candidates per ring, number of rings, distance between the bounds and rings. |
| Allow Roof Exit | On | Last resort: on top of the vehicle. |
| Default Radius / Default Half Height | 40 / 90 | Capsule when the pawn has no collision shape. |
| Draw Debug | Off | Draws every tested capsule for 3 s (green free, red blocked), development builds. |
Library: Is Capsule Free and Get Pawn Collision Size for your own placement checks.
7. Left-behind pawns
enum EPawnSwapLeftBehind decides what happens to the controller of the pawn you leave:
| Value | Result |
|---|---|
| Leave Unpossessed | The pawn stays without a controller. |
| Spawn AI Controller | The pawn spawns its AI Controller Class and is possessed by it. |
| Restore Original Controller | The controller that had the pawn before you took it (for example its AI) gets it back; falls back to Spawn AI Controller. |
Used by the manager's Left Behind Policy (default Leave Unpossessed), a profile's Left Behind Policy when Override Left Behind is on (profile default Spawn AI Controller), and the seat's Vehicle On Exit for the vehicle a driver leaves (default Leave Unpossessed). A driver who switches away keeps sitting in the vehicle, which stays unpossessed; switching back to that pawn resumes driving.
8. Seated occupant
| Property | Default | Description |
|---|---|---|
| Occupant Socket | None | Socket of the component the seat is attached to (for example a skeletal mesh socket of a mount). None = attach to the seat itself. |
| Occupant Offset | identity | Location/rotation relative to the seat or socket (for example a capsule half height up so the feet are on the floor). |
| Hide Occupant | Off | Hidden while seated (enclosed cockpits). |
| Disable Occupant Collision | On | Actor collision off while seated. |
| Disable Occupant Movement | On | Character movement set to None (other movement components are deactivated). |
| Ignore Controller Rotation | On | Use Controller Rotation Pitch/Yaw/Roll off while seated, so a passenger can look around without turning in the seat. |
The previous state (collision, visibility, movement, controller rotation flags) is stored when the pawn sits down and restored when it leaves; the pawn is detached and stood upright. The same handling runs on every machine through the occupancy RepNotify, so collision and movement are correct on clients too.
9. Interaction query
Find Best Interaction returns an struct FPawnSwapInteraction: Type (None, Seat, Pawn, Exit), Seat, Pawn, Distance, View Angle, Prompt and Deny Reason. While seated it returns Exit. Interact runs the best one (enter, take over, exit); Interact With runs a given result.
Settings (Interaction, FPawnSwapInteractionSettings):
| Field | Default | Description |
|---|---|---|
| Radius | 350 | Maximum distance from the controlled pawn to the entry point or pawn. |
| Max View Angle | 60 | Degrees between the view direction and the target. |
| Angle Weight | 0.6 | 0 = nearest wins, 1 = closest to the view centre wins. |
| Include Seats / Include Pawns | On / On | Pawns need a profile with Switchable By Interaction. |
| Include Denied | Off | Also return refused targets (Deny Reason filled) to show "Locked". |
| Require Line Of Sight / Line Of Sight Channel | Off / Visibility | Clear line from the view point to the target. |
Auto Scan Interaction (default off) queries every Scan Interval seconds (default 0.1) on the owning client and fires event On Interaction Changed when the target changes; Get Current Interaction returns the last result.
10. Locks & access
| Property | Default | Description |
|---|---|---|
| Locked | Off | Refuses everyone (Locked). Replicated; change with Set Locked (server). |
| Access | Anyone | Anyone, Owner Only, Same Team, Owner Or Same Team. Replicated; Set Access. |
| Team Id | 0 | Seat team for Same Team rules. Replicated; Set Team Id. |
| Claim On First Enter | On | Owner rules: the first player to enter an unowned seat becomes its owner (their Player State). |
Set Seat Owner (server) accepts a controller, player state or pawn; Get Seat Owner reads it. A pawn's team is its profile Team Id when 0 or more, otherwise the manager's Team Id (default 0, set with Set Team Id on the server). Check Access (Candidate, Controller) returns the deny reason without entering. Override event Check Custom Access in a seat subclass for keys, factions or quest state (refused with Custom Rule).
11. Events
| Event | On | Parameters |
|---|---|---|
| On Pawn Switched | Manager | New Pawn, Old Pawn |
| On Seat Entered / On Seat Exited | Manager | Seat, Seated Pawn |
| On Enter Denied / On Exit Denied | Manager | Reason, Seat |
| On Switch Denied | Manager | Reason, Target Pawn |
| On Setup Input | Manager | New Pawn, Old Pawn (owning client, see Input) |
| On Spectate Changed | Manager | Target, Spectating |
| On Interaction Changed | Manager | Interaction |
| On Occupant Changed | Seat | Seat, New Occupant, Previous Occupant (every machine) |
| On Swap Possessed / On Swap Released | Profile | New Controller |
Manager switch, seat and deny events fire on the server and on the owning client (once in standalone and on a listen-server host). enum EPawnSwapDenyReason: None, Invalid Target, No Pawn, No Authority, Locked, Not Owner, Wrong Team, Occupied, Out Of Range, Already Seated, Not Seated, Exit Blocked, Controlled By Other Player, Not In Roster, Already Controlled, Cooldown, Custom Rule.
12. Multiplayer
- Switch, enter, exit and change-seat calls made on a client go to the server with reliable Server RPCs; the server validates everything (roster, access, range, exit space) and answers through the events.
- Seat Occupant replicates with a RepNotify that attaches/detaches and applies/restores the occupant state on every client; lock, access rule, team and owner replicate too.
- The roster, the current seat and the team id replicate to the owning client only.
- Camera blends reach remote clients through the engine's view-target replication; the manager holds the client's automatic camera during the possession so the blend is not cut.
- After an exit the server teleports the pawn and sends the owning client its new location.
13. Spectate
| Node | Type | Description |
|---|---|---|
| Spectate (Target) | call | Blends the view to any actor without possessing it. Call again to move to another target. |
| Spectate Roster (Direction) | call | Next (1) or previous (-1) roster pawn other than yours. |
| Stop Spectating (Blend) | call | Returns the view to the controlled pawn. |
| Is Spectating / Get Spectate Target | pure | State. |
Spectating is a view change on the owning client (the server keeps you possessing your pawn). Ignore Input While Spectating (default on) blocks move and look input until you return; any possession change ends spectating.
14. Input per pawn
struct FPawnSwapInputSettings — applied on the owning client after every switch: the new pawn's profile Input when Override Input is on, else the manager's Default Input.
| Field | Default | Description |
|---|---|---|
| Mode | Unchanged | Unchanged, Game Only, Game And UI, UI Only. |
| Set Mouse Cursor / Show Mouse Cursor | Off / Off | Changes the cursor visibility. |
| Lock Mouse To Viewport | Off | Game And UI / UI Only mouse lock. |
| Hide Cursor During Capture | On | Game And UI. |
Then event Setup Input For Pawn (overridable in a manager subclass) and event On Setup Input fire: add input mapping contexts, bind actions or show the pawn's HUD there. Apply Input Settings applies a settings struct at any time.
15. Save / restore
Export State returns struct FPawnSwapSaveData (all fields marked SaveGame): Pawns (actor name, roster tag, class, transform), Active Index (your pawn, or the driver while driving) and Seats occupied by roster pawns (vehicle name/tag, seat name, occupant index, driving, locked). Store it in your SaveGame object.
Restore State (Data, Restore Transforms, Spawn Missing) on the server: frees the seats held by your pawns, finds each pawn by Roster Tag (profile tag or first actor tag) or by actor name, respawns missing ones from their class when Spawn Missing is on, moves them when Restore Transforms is on, rebuilds the roster, re-seats the occupants, restores seat locks and possesses the active pawn (or its vehicle when it was driving). Both default to on.
Pawn Swap Profile
Component UPawnSwapPawnComponent — displayed as Pawn Swap Profile. Optional, on any pawn.
| Property | Default | Description |
|---|---|---|
| Roster Tag | None | Key for Switch To Tag and save/restore. |
| Display Name | empty | Name for UI. |
| Team Id | -1 | -1 = use the controller's manager team. |
| Auto Register / Auto Register Player Index | Off / 0 | Registers the pawn with that player's manager on the server (-1 = every player; retried while players join). |
| Switchable By Interaction / Interaction Prompt | Off / Take control | Offered by interaction queries and accepted by Switch To Pawn without being in the roster. |
| Override Left Behind / Left Behind Policy | Off / Spawn AI Controller | Controller policy when a player leaves this pawn. |
| Override Blend / Blend | Off / 0.5 s Ease In Out | Camera blend when switching to this pawn. |
| Override Input / Input | Off / Unchanged | Input mode when this pawn becomes controlled. |
Blueprint library
Function Library UPawnSwapLibrary — category PawnSwap.
| Node | Type | Description |
|---|---|---|
| Get Manager Of Controller / Get Manager Of Pawn | pure | The Pawn Swap Manager of a controller, or of the controller of a pawn. |
| Get Pawn Profile | pure | The Pawn Swap Profile of a pawn. |
| Get Seats / Get Driver Seat / Get Free Seat / Get Occupants | pure | Seats of a vehicle (by Priority), its driver seat, the best free seat for a pawn, seated pawns. |
| Find Seat Of Pawn / Is Pawn Seated | pure | Where a pawn sits. |
| Get Pawn Team Id | pure | Team used by access rules. |
| Get Pawn Collision Size / Is Capsule Free | pure / call | Capsule of a pawn and a free-space test. |
| Get Save Key | pure | The key save data uses for an actor. |
C++
#include "PawnSwapManagerComponent.h"
#include "PawnSwapSeatComponent.h"
#include "PawnSwapLibrary.h"
// In your PlayerController
UPROPERTY(VisibleAnywhere)
UPawnSwapManagerComponent* Swap;
AMyPlayerController::AMyPlayerController()
{
Swap = CreateDefaultSubobject<UPawnSwapManagerComponent>(TEXT("Swap"));
Swap->SwitchBlend.BlendTime = 0.4f;
Swap->LeftBehindPolicy = EPawnSwapLeftBehind::SpawnAIController;
Swap->bAutoScanInteraction = true;
}
void AMyPlayerController::OnInteractPressed() { Swap->Interact(); }
void AMyPlayerController::OnNextPressed() { Swap->SwitchToNext(); }
// AI passenger (server)
if (UPawnSwapSeatComponent* Seat = UPawnSwapLibrary::GetFreeSeat(Bus, Npc, false))
{
Seat->SeatPawn(Npc);
}
// Save game
MySave->Swap = Swap->ExportState();
Swap->RestoreState(MySave->Swap, true, true);
Troubleshooting
| Symptom | Cause and fix |
|---|---|
| Switch is refused with Not In Roster | Register the pawn on the server (Register Pawn or a profile with Auto Register), or turn off Require Roster. |
| Nothing happens on a client | The manager must be on the PlayerController (the only actor a client may send Server RPCs from), and vehicles must replicate. |
| The camera cuts instead of blending | Check Manage Camera and the blend time. On clients the target pawn must already be replicated (relevant); a far pawn that is not yet relevant is cut to when it arrives. |
| Exit Blocked although there is room | Exit points may be inside the vehicle collision or below the ground: turn on Draw Debug in Exit Settings. Raise Max Ground Distance on uneven terrain. |
| The occupant floats or sinks in the seat | Characters attach at their capsule centre: move the seat component, or adjust Occupant Offset (location and rotation relative to the seat or socket). |
| Restore State finds nothing | Runtime-spawned actors need a Roster Tag or actor tag; keep Spawn Missing on to recreate pawns. |
Credits
© 2026 Alpha XP — alphaxp.net · Support: support@alphaxp.net. Built for Unreal Engine 4.27 and 5.8.