AGameState

GameState is a subclass of GameStateBase that behaves like a multiplayer match-based game.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/GameFramework/GameState.h

Include

#include "GameFramework/GameState.h"

Syntax

class AGameState : public AGameStateBase

Remarks

GameState is a subclass of GameStateBase that behaves like a multiplayer match-based game. It is tied to functionality in GameMode.

Variables

Name Description

Public variable

int32

 

ElapsedTime

Elapsed game time since match has started.

Protected variable

FName

 

MatchState

What match state we are currently in

Protected variable

FName

 

PreviousMatchState

Previous map state, used to handle if multiple transitions happen per frame

Protected variable

FTimerHandle

 

TimerHandle_DefaultTimer

Handle for efficient management of DefaultTimer timer

Constructors

Name Description

Public function

AGameState

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function Virtual

void

 

DefaultTimer()

Called periodically, overridden by subclasses

Public function Const

FName

 

GetMatchState()

Returns the current match state, this is an accessor to protect the state machine flow

Protected function Virtual

void

 

HandleLeavingMap()

Called when the match transitions to LeavingMap

Protected function Virtual

void

 

HandleMatchHasEnded()

Called when the map transitions to WaitingPostMatch

Protected function Virtual

void

 

HandleMatchHasStarted()

Called when the state transitions to InProgress

Protected function Virtual

void

 

HandleMatchIsWaitingToStart()

Called when the state transitions to WaitingToStart

Public function Virtual Const

bool

 

HasMatchEnded()

Returns true if match is WaitingPostMatch or later

Public function Virtual Const

bool

 

IsMatchInProgress()

Returns true if we're in progress

Public function Virtual

void

 

OnRep_ElapsedTime()

Gives clients the chance to do something when time gets updates

Public function Virtual

void

 

OnRep_MatchState()

Match state has changed

Public function

void

 

SetMatchState

(
    FName NewState
)

Updates the match state and calls the appropriate transition functions, only valid on server

Overridden from AGameStateBase

Name Description

Public function Virtual Const

float

 

GetPlayerRespawnDelay

(
    AController* Controller
)

Returns how much time needs to be spent before a player can respawn

Public function Virtual Const

float

 

GetPlayerStartTime

(
    AController* Controller
)

Returns the time that should be used as when a player started

Public function Virtual

void

 

HandleBeginPlay()

Called by game mode to set the started play bool

Public function Virtual Const

bool

 

HasMatchStarted()

Returns true if the world has started match (called MatchStarted callbacks)

Public function Virtual

void

 

ReceivedGameModeClass()

Called when the GameClass property is set (at startup for the server, after the variable has been replicated on clients)

Overridden from AActor

Name Description

Public function Virtual

void

 

PostInitializeComponents()

Allow actors to initialize themselves on the C++ side after all of their components have been initialized, only called during gameplay

Deprecated Functions

Name Description

Public function Virtual Const

bool

 

ShouldShowGore()

ShouldShowGore is deprecated, it is not supported by newer assets

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss