AGameModeBase::PlayerCanRestart
#include "GameFramework/GameModeBase.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallableBlueprintNativeEvent
Description
Returns true if a player is currently allowed to respawn. The default implementation delegates to APlayerController::CanRestartPlayer. Override to add cooldowns, round state checks, or team-based restrictions.
Caveats & Gotchas
- • RestartPlayer calls this before spawning a pawn — returning false prevents the spawn. However, if you call RestartPlayerAtPlayerStart directly, PlayerCanRestart is NOT checked, bypassing your gate.
- • The default implementation calls Player->CanRestartPlayer(), which checks that the controller is not currently in the middle of a respawn. If you override this, consider still calling the super or manually checking that condition.
- • Spectators also go through this check when transitioning to active play, so make sure your override handles the case where the player has no pawn and is spectating.
Signature
ENGINE_API bool PlayerCanRestart(APlayerController* Player); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Player | APlayerController* | The player controller requesting to restart. | — |
Return Type
bool Example
Enforce respawn cooldown C++
bool AMyGameMode::PlayerCanRestart_Implementation(APlayerController* Player)
{
if (!Super::PlayerCanRestart_Implementation(Player))
{
return false;
}
AMyPlayerState* PS = Player ? Cast<AMyPlayerState>(Player->PlayerState) : nullptr;
if (PS && PS->RespawnCooldownRemaining > 0.0f)
{
return false;
}
return true;
} Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?