APawn::SetPlayerDefaults
#include "GameFramework/Pawn.h"
Access: public
Specifiers: virtual
Description
Resets the pawn's properties to their default values. Called by `GameMode::RestartPlayer` before (re)possessing the pawn to ensure a clean state.
Caveats & Gotchas
- • Override this to reset gameplay state (ammo, health, abilities) when a player respawns. The base `APawn` implementation does nothing — you must call `Super::SetPlayerDefaults()` only if a subclass like `ACharacter` adds logic.
- • This is called by `AGameModeBase::RestartPlayer`, not by `PossessedBy`, so it may be called before possession is complete.
Signature
virtual void SetPlayerDefaults() Return Type
void Example
Reset health on respawn C++
void AMyPawn::SetPlayerDefaults()
{
Super::SetPlayerDefaults();
Health = MaxHealth;
Ammo = MaxAmmo;
} See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?