AGameState

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

Windows
MacOS
Linux

Inheritance Hierarchy

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

References

Module

Engine

Header

Runtime/Engine/Classes/GameFramework/GameState.h

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback