Navigation
API > API/Runtime > API/Runtime/Engine
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.
| Name | AGameStateBase |
| Type | class |
| Header File | /Engine/Source/Runtime/Engine/Classes/GameFramework/GameStateBase.h |
| Include Path | #include "GameFramework/GameStateBase.h" |
Syntax
UCLASS (Config=Game, NotPlaceable, BlueprintType, Blueprintable, MinimalAPI)
class AGameStateBase : public AInfo
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → AActor → AInfo → AGameStateBase
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
AGameStateBase
(
const FObjectInitializer& ObjectInitializer |
GameFramework/GameStateBase.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| AuthorityGameMode | TObjectPtr< AGameModeBase > | Instance of the current game mode, exists only on the server. | GameFramework/GameStateBase.h |
|
| GameModeClass | TSubclassOf< AGameModeBase > | Class of the server's game mode, assigned by GameModeBase. | GameFramework/GameStateBase.h |
|
| PlayerArray | TArray< TObjectPtr< APlayerState > > | Array of all PlayerStates, maintained on both server and clients (PlayerStates are always relevant) | GameFramework/GameStateBase.h |
|
| SpectatorClass | TSubclassOf< ASpectatorPawn > | Class used by spectators, assigned by GameModeBase. | GameFramework/GameStateBase.h |
|
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void AddPlayerState
(
APlayerState* PlayerState |
Add PlayerState to the PlayerArray | GameFramework/GameStateBase.h | |
virtual void AsyncPackageLoaded
(
UObject* Package |
Allow game states to react to asset packages being loaded asynchronously | GameFramework/GameStateBase.h | |
const AGameModeBase * GetDefaultGameMode () |
Helper to return the default object of the GameModeBase class corresponding to this GameState. | GameFramework/GameStateBase.h | |
const T * GetDefaultGameMode () |
Helper template to returns the GameModeBase default object cast to the right type | GameFramework/GameStateBase.h | |
virtual float GetPlayerRespawnDelay
(
AController* Controller |
Returns how much time needs to be spent before a player can respawn | GameFramework/GameStateBase.h |
|
virtual float GetPlayerStartTime
(
AController* Controller |
Returns the time that should be used as when a player started | GameFramework/GameStateBase.h |
|
APlayerState * GetPlayerStateFromUniqueNetId
(
const FUniqueNetIdWrapper& InPlayerId |
Returns the player state for a specified unique player Id | GameFramework/GameStateBase.h | |
virtual double GetServerWorldTimeSeconds() |
Returns the simulated TimeSeconds on the server, will be synchronized on client and server | GameFramework/GameStateBase.h |
|
virtual void HandleBeginPlay() |
Called by game mode to set the started play bool | GameFramework/GameStateBase.h | |
virtual bool HasBegunPlay() |
Returns true if the world has started play (called BeginPlay on actors) | GameFramework/GameStateBase.h |
|
virtual bool HasMatchEnded() |
Returns true if the match can be considered ended. Defaults to false. | GameFramework/GameStateBase.h |
|
virtual bool HasMatchStarted() |
Returns true if the world has started match (called MatchStarted callbacks) | GameFramework/GameStateBase.h |
|
virtual void ReceivedGameModeClass() |
Called when the GameClass property is set (at startup for the server, after the variable has been replicated on clients) | GameFramework/GameStateBase.h | |
virtual void ReceivedSpectatorClass() |
Called when the SpectatorClass property is set (at startup for the server, after the variable has been replicated on clients) | GameFramework/GameStateBase.h | |
virtual void RemovePlayerState
(
APlayerState* PlayerState |
Remove PlayerState from the PlayerArray. | GameFramework/GameStateBase.h | |
virtual void SeamlessTravelTransitionCheckpoint
(
bool bToTransitionMap |
Called during seamless travel transition twice (once when the transition map is loaded, once when destination map is loaded) | GameFramework/GameStateBase.h |
Overridden from AActor
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void PostInitializeComponents() |
Allow actors to initialize themselves on the C++ side after all of their components have been initialized, only called during gameplay | GameFramework/GameStateBase.h |
Overridden from UObject
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void GetLifetimeReplicatedProps
(
TArray< FLifetimeProperty >& OutLifetimeProps |
Returns the properties used for network replication, this needs to be overridden by all actor classes with native replicated properties | GameFramework/GameStateBase.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void OnRep_GameModeClass() |
GameModeBase class notification callback. | GameFramework/GameStateBase.h | |
virtual void OnRep_ReplicatedHasBegunPlay() |
By default calls BeginPlay and StartMatch | GameFramework/GameStateBase.h | |
virtual void OnRep_ReplicatedWorldTimeSecondsDouble() |
Allows clients to calculate ServerWorldTimeSecondsDelta | GameFramework/GameStateBase.h | |
virtual void OnRep_SpectatorClass() |
Callback when we receive the spectator class | GameFramework/GameStateBase.h | |
virtual void UpdateServerTimeSeconds() |
Called periodically to update ReplicatedWorldTimeSecondsDouble | GameFramework/GameStateBase.h |