AGameStateBase::RemovePlayerState
#include "GameFramework/GameStateBase.h"
Access: public
Specifiers: virtual
Description
Removes the given `APlayerState` from `PlayerArray`. Called automatically when a player disconnects; override if you maintain supplementary per-player data structures alongside `PlayerArray`.
Caveats & Gotchas
- • The pointer may already be garbage-collected by the time you access it in an override — always guard with `IsValid()` before dereferencing inside your override.
- • Calling `Super::RemovePlayerState` removes the entry from `PlayerArray` by pointer comparison. If you duplicated the entry via `AddPlayerState`, only the first match is removed.
Signature
ENGINE_API virtual void RemovePlayerState(APlayerState* PlayerState) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| PlayerState | APlayerState* | The player state to remove from `PlayerArray`. | — |
Return Type
void Example
Clean up score tracking on disconnect C++
void AMyGameState::RemovePlayerState(APlayerState* PlayerState)
{
Super::RemovePlayerState(PlayerState);
PlayerScores.Remove(PlayerState);
} Tags
Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?