RealDocs

APlayerState::Destroyed

function Engine Since 4.0
#include "GameFramework/PlayerState.h"
Access: public Specifiers: virtualoverrideENGINE_API

Description

Called when this PlayerState is destroyed. The base implementation unregisters the player from the online session via UnregisterPlayerWithSession.

Caveats & Gotchas

  • Always call Super::Destroyed() when overriding — skipping it leaks the player's online session registration, which can prevent others from joining if the session has a player count limit.
  • In networked games, Destroyed is called on the server when the player disconnects. On clients it is called when the replicated actor is torn down — timing differs between server and client.

Signature

ENGINE_API virtual void Destroyed() override;

Return Type

void

Example

Override to clean up custom per-player data C++
void AMyPlayerState::Destroyed()
{
    // Clean up custom resources before calling super
    if (UMySubsystem* Sub = GetGameInstance()->GetSubsystem<UMySubsystem>())
    {
        Sub->RemovePlayer(this);
    }
    Super::Destroyed();
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.