class

AGameMode

Module
Game
Header
#include "Game/AGameMode.h"
Namespace
Mowo
Reflection
Reflected by MowoHeaderTool

Properties

TypeNameDescription
TSubclassOf<APawn>defaultPawnClassClasses to spawn. nullptr = the base type (APawn / APlayerController / AGameState). Editable in Details and saved with the level, so a designer picks the pawn instead of a constructor naming it; a Visual Scripting class counts as a pawn when it derives from APawn.
TSubclassOf<APlayerController>playerControllerClass
TSubclassOf<AGameState>gameStateClass
int32_tplayerIndexDefault 0.
boolspawnLocalPlayerOnStartDefault true.

Constructors

SignatureNameDescription
AGameMode() = defaultAGameMode

Public functions

ReturnsNameDescription
voidInitGameCalled by MWorld::InitializeGameMode right after the game mode itself spawns — before StartMatch.
voidStartMatchSpawns GameState + PlayerController + default pawn, possesses, flips match state to InProgress.
APawn*SpawnDefaultPawn
APawn*RestartPlayerUE5 RestartPlayer: spawn a defaultPawnClass pawn at the APlayerStart matching playerStartIndex (-1 = any) and possess it with the given controller.
APlayerStart*FindPlayerStart
voidSetStartOverridePlay From Here (the editor's right-click on the level): the next pawn the game mode places for the LOCAL player spawns at this transform instead of at an APlayerStart.
voidClearStartOverride
boolHasStartOverride
AGameState*GetGameState
APlayerController*GetPlayerController
boolHasMatchStarted
voidPostLoginPlayer arrival and departure, UE's PostLogin / Logout.
voidLogout
MulticastDelegate<AController*, APawn*>&OnPostLogin
MulticastDelegate<AController*>&OnLogout
voidNotifyPostLogin
voidNotifyLogout
int32_tGetNumPlayers
voidTickAdvances match time on the game state.

Function details

AGameMode

C++
AGameMode() = default

InitGame

C++
virtual void InitGame()

Called by MWorld::InitializeGameMode right after the game mode itself spawns — before StartMatch. Override for rule setup that must precede any spawning.

StartMatch

C++
virtual void StartMatch()

Spawns GameState + PlayerController + default pawn, possesses, flips match state to InProgress. Idempotent (second call no-ops). A dedicated server sets spawnLocalPlayerOnStart false first — the match starts with no local player and pawns arrive per connection through RestartPlayer.

SpawnDefaultPawn

C++
virtual APawn* SpawnDefaultPawn()

RestartPlayer

C++
virtual APawn* RestartPlayer(AController* controller, int32_t playerStartIndex = -1)

UE5 RestartPlayer: spawn a defaultPawnClass pawn at the APlayerStart matching playerStartIndex (-1 = any) and possess it with the given controller. The join path (FNetSession::ServerSpawnPawnFor) calls this once per connecting player.

FindPlayerStart

C++
APlayerStart* FindPlayerStart(int32_t index) const

SetStartOverride

C++
static void SetStartOverride(const Vec3& location, const Quat& rotation)

Play From Here (the editor's right-click on the level): the next pawn the game mode places for the LOCAL player spawns at this transform instead of at an APlayerStart. One-shot — consumed by that placement and cleared by the editor when play stops — and process-wide because the game mode that will read it does not exist yet when the editor decides where play begins.

ClearStartOverride

C++
static void ClearStartOverride()

HasStartOverride

C++
static bool HasStartOverride()

GetGameState

C++
AGameState* GetGameState() const

GetPlayerController

C++
APlayerController* GetPlayerController() const

HasMatchStarted

C++
bool HasMatchStarted() const

PostLogin

C++
virtual void PostLogin(AController* controller, APawn* pawn)

Player arrival and departure, UE's PostLogin / Logout. PostLogin fires once a controller holds its first pawn — the local player's at StartMatch, a joining peer's after RestartPlayer — and Logout right before a departing player's controller is torn down. Override the virtuals in a game mode subclass or bind the delegates from anywhere.

Logout

C++
virtual void Logout(AController* controller)

OnPostLogin

C++
MulticastDelegate<AController*, APawn*>& OnPostLogin()

OnLogout

C++
MulticastDelegate<AController*>& OnLogout()

NotifyPostLogin

C++
void NotifyPostLogin(AController* controller, APawn* pawn)

NotifyLogout

C++
void NotifyLogout(AController* controller)

GetNumPlayers

C++
int32_t GetNumPlayers() const

Tick

C++
void Tick(float deltaSeconds) override

Advances match time on the game state.

Generated from Game/AGameMode.h via game.json · Nov 5, 2026Version 1.0.0