RealDocs

AGameModeBase

class Engine Since 4.14
#include "GameFramework/GameModeBase.h"
Access: public Specifiers: UCLASS

Description

Server-only actor that defines the rules of the game: which pawn class to spawn, how players log in and respawn, and game flow. Only one GameMode is active per world and it exists solely on the server (or in single-player). Clients never receive a reference to the GameMode.

Signature

UCLASS() class AGameModeBase : public AInfo

Caveats & Gotchas

  • Use `AGameMode` (which extends this) if you need match-state transitions (WaitingToStart, InProgress, WaitingPostMatch).
  • The GameMode class is set per-level via World Settings or by URL options; blueprint subclasses are the typical customization path.
  • Access via `GetWorld()->GetAuthGameMode<AMyGameMode>()` — returns nullptr on clients.

Examples

Set in project defaults C++
// In DefaultEngine.ini:
// [/Script/EngineSettings.GameMapsSettings]
// GlobalDefaultGameMode=/Game/GameModes/BP_MyGameMode.BP_MyGameMode_C
Access on server C++
AMyGameMode* GM = GetWorld()->GetAuthGameMode<AMyGameMode>();
if (GM) { GM->EndMatch(); }

Functions (4)

Utility
4
Access Type Name
public function AGameModeBase::GetDefaultPawnClassForController
public function AGameModeBase::InitGame
public function AGameModeBase::RestartPlayer
public function AGameModeBase::SpawnDefaultPawnFor

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.