RealDocs

AGameModeBase::RestartPlayer

function Engine Since 4.14
#include "GameFramework/GameModeBase.h"
Access: public Specifiers: virtual

Description

Finds a player start, spawns the default pawn, and possesses it — the full respawn flow in a single call. The most common override point for custom respawn logic such as team-based spawns, respawn delays, or spectator transitions.

Signature

virtual void RestartPlayer(AController* NewPlayer)

Parameters

Name Type Description Default
NewPlayer AController* The controller to respawn.

Return Type

void

Caveats & Gotchas

  • Only valid on the server.
  • Calls `FindPlayerStart`, `SpawnDefaultPawnFor`, and `Possess` in order; if any step fails the player is not respawned and no error is thrown.
  • Call `CanRestartPlayer()` first if you need a conditional guard before respawning.

Example

Respawn after a delay C++
void AMyGameMode::OnPlayerDied(AController* Player)
{
    FTimerHandle Handle;
    GetWorldTimerManager().SetTimer(Handle, [this, Player]()
    {
        RestartPlayer(Player);
    }, RespawnDelay, false);
}

Version History

Introduced in: 4.14

Version Status Notes
5.6 stable
5.0 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.