AGameStateBase::GetDefaultGameMode
#include "GameFramework/GameStateBase.h"
Access: public
Specifiers: const
Description
Returns the CDO (class default object) of the game mode class associated with this game state. Use it to read default configuration values without needing a live game mode instance.
Caveats & Gotchas
- • This returns the *default object*, not the live `AGameModeBase` instance — modifying its properties has no effect and will be overwritten. Never cast away const to write to it.
- • Can return null if `GameModeClass` has not been replicated yet on clients; guard with a null-check before dereferencing.
- • A templated overload `GetDefaultGameMode<T>()` exists for strongly-typed access without a manual Cast.
Signature
ENGINE_API const AGameModeBase* GetDefaultGameMode() const Return Type
const AGameModeBase* Example
Read default respawn time from any client C++
if (const AMyGameMode* DefaultMode = GetGameState<AGameStateBase>()->GetDefaultGameMode<AMyGameMode>())
{
float DefaultRespawn = DefaultMode->RespawnDelay;
} Tags
Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?