AGameStateBase::AuthorityGameMode
#include "GameFramework/GameStateBase.h"
Access: public
Specifiers: UPROPERTYTransientBlueprintReadOnly
Description
Reference to the active GameMode instance. Only valid on the server — this property is always null on clients, even when accessed from Blueprint.
Caveats & Gotchas
- • Always null on clients — this is intentional. GameMode does not exist on clients; the GameState is the only shared game-rules object that replicates. If you're reading this from a client context, the result will be null.
- • Not replicated — the property is marked Transient and has no ReplicatedUsing callback. If you need to expose game mode configuration to clients, put it on the GameState itself as a replicated property.
- • Accessing this in BeginPlay on a listen server is safe; on a dedicated server client, it will be null until after the GameState actor has been received and AuthorityGameMode has been set by the GameMode.
Signature
UPROPERTY(Transient, BlueprintReadOnly, Category=GameState)
TObjectPtr<AGameModeBase> AuthorityGameMode; Example
Access game mode settings from the game state (server only) C++
// Safe to use inside server-side GameState code
void AMyGameState::ServerOnlyLogic()
{
if (AuthorityGameMode)
{
AMyGameMode* GM = Cast<AMyGameMode>(AuthorityGameMode);
if (GM)
{
UE_LOG(LogTemp, Log, TEXT("Round time: %f"), GM->RoundDuration);
}
}
} Tags
Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?