UGameplayStatics::RemovePlayer
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallable
Description
Removes a local player from the game, cleaning up their PlayerController and optionally their pawn. Used to disconnect a player in split-screen or local multiplayer.
Caveats & Gotchas
- • You cannot remove the primary player (player index 0). Attempting to do so has no effect and will log a warning.
- • If bDestroyPawn is false and the pawn remains in the world, nothing automatically re-possesses it — it will become an AI-controlled orphan unless you handle it manually.
- • Calling this during Actor construction is flagged as unsafe in Blueprint (UnsafeDuringActorConstruction meta).
Signature
static ENGINE_API void RemovePlayer(APlayerController* Player, bool bDestroyPawn); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Player | APlayerController* | The PlayerController of the local player to remove. | — |
| bDestroyPawn | bool | If true, the pawn currently possessed by this controller is also destroyed. | — |
Return Type
void Example
Remove the second local player and destroy their pawn C++
APlayerController* P2 = UGameplayStatics::GetPlayerController(this, 1);
if (P2)
{
UGameplayStatics::RemovePlayer(P2, true);
} Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?