Language:
Discover
By Skill Level
By Category

AGameStateBase

Choose your OS:

Inheritance Hierarchy

Syntax

class AGameStateBase : public AInfo

Remarks

GameStateBase is a class that manages the game's global state, and is spawned by GameModeBase. It exists on both the client and the server and is fully replicated.

Variables

Name Description

Public variable

AGameModeBase &...

 

AuthorityGameMode

Instance of the current game mode, exists only on the server.

Protected variable

bool

 

bReplicatedHasBegunPlay

Replicated when GameModeBase->StartPlay has been called so the client will also start play

Public variable

TSubclassOf < AG ...

 

GameModeClass

General accessors and variables.

Public variable

TArray < APlayer ...

 

PlayerArray

Array of all PlayerStates, maintained on both server and clients (PlayerStates are always relevant)

Protected variable

float

 

ReplicatedWorldTimeSeconds

Server TimeSeconds. Useful for syncing up animation and gameplay.

Protected variable

float

 

ServerWorldTimeSecondsDelta

The difference from the local world's TimeSeconds and the server world's TimeSeconds.

Protected variable

float

 

ServerWorldTimeSecondsUpdateFrequency

Frequency that the server updates the replicated TimeSeconds from the world.

Public variable

TSubclassOf < AS ...

 

SpectatorClass

Class used by spectators, assigned by GameModeBase.

Protected variable

FTimerHandle

 

TimerHandle_UpdateServerTimeSeconds

Handle for efficient management of the UpdateServerTimeSeconds timer

Constructors

Name Description

Public function

AGameStateBase

(
    const FObjectInitializer & ObjectIn...
)

Functions

Name Description

Public function Virtual

void

 

AddPlayerState

(
    APlayerState * PlayerState
)

Add PlayerState to the PlayerArray

Public function Virtual

void

 

AsyncPackageLoaded

(
    UObject * Package
)

Allow game states to react to asset packages being loaded asynchronously

Public function

const AGameM ...

 

GetDefaultGameMode()

Helper to return the default object of the GameModeBase class corresponding to this GameState.

Public function

const T *...

 

GetDefaultGameMode()

Helper template to returns the GameModeBase default object cast to the right type

Public function Virtual

float

 

GetPlayerRespawnDelay

(
    AController * Controller
)

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

Public function Virtual

float

 

GetPlayerStartTime

(
    AController * Controller
)

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

Public function Virtual

float

 

GetServerWorldTimeSeconds()

Returns the simulated TimeSeconds on the server, will be synchronized on client and server

Public function Virtual

void

 

HandleBeginPlay()

Called by game mode to set the started play bool

Public function Virtual

bool

 

HasBegunPlay()

Returns true if the world has started play (called BeginPlay on actors)

Public function Virtual

bool

 

HasMatchStarted()

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

Protected function Virtual

void

 

OnRep_GameModeClass()

GameModeBase class notification callback.

Protected function Virtual

void

 

OnRep_ReplicatedHasBegunPlay()

By default calls BeginPlay and StartMatch

Protected function Virtual

void

 

OnRep_ReplicatedWorldTimeSeconds()

Allows clients to calculate ServerWorldTimeSecondsDelta

Protected function Virtual

void

 

OnRep_SpectatorClass()

Callback when we receive the spectator class

Public function Virtual

void

 

ReceivedGameModeClass()

Interaction with GameModeBase.

Public function Virtual

void

 

ReceivedSpectatorClass()

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

Public function Virtual

void

 

RemovePlayerState

(
    APlayerState * PlayerState
)

Remove PlayerState from the PlayerArray.

Public function Virtual

void

 

SeamlessTravelTransitionCheckpoint

(
    bool bToTransitionMap
)

Called during seamless travel transition twice (once when the transition map is loaded, once when destination map is loaded)

Protected function Virtual

void

 

UpdateServerTimeSeconds()

Called periodically to update ReplicatedWorldTimeSeconds

Overridden from AActor

Name Description

Public function Virtual

void

 

PostInitializeComponents()

Allow actors to initialize themselves on the C++ side

Overridden from UObject

Name Description

Public function Virtual

void

 

GetLifetimeReplicatedProps

(
    TArray < FLifetimeProperty >& OutLi...
)

Returns the properties used for network replication

References

Module

Engine

Header

Runtime/Engine/Classes/GameFramework/GameStateBase.h