Navigation
API > API/Runtime > API/Runtime/Engine > API/Runtime/Engine/GameFramework
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- AActor
- AInfo
- AGameStateBase
- AGameState
- AMoverExamplesGameState
References
| Module | Engine |
| Header | /Engine/Source/Runtime/Engine/Classes/GameFramework/GameStateBase.h |
| Include | #include "GameFramework/GameStateBase.h" |
Syntax
UCLASS (Config=Game, NotPlaceable, BlueprintType, Blueprintable, MinimalAPI)
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
| Type | Name | Description | |
|---|---|---|---|
| TObjectPtr< AGameModeBase > | AuthorityGameMode | Instance of the current game mode, exists only on the server. | |
| bool | bReplicatedHasBegunPlay | Replicated when GameModeBase->StartPlay has been called so the client will also start play | |
| TSubclassOf< AGameModeBase > | GameModeClass | Class of the server's game mode, assigned by GameModeBase. | |
| uint32 | NumServerWorldTimeSecondsDeltas | The number of server world time deltas accumulated in SumServerWorldTimeSecondsDelta - used for computing the mean | |
| TArray< TObjectPtr< APlayerState > > | PlayerArray | Array of all PlayerStates, maintained on both server and clients (PlayerStates are always relevant) | |
| float | ReplicatedWorldTimeSeconds | Server TimeSeconds. Useful for syncing up animation and gameplay. | |
| double | ReplicatedWorldTimeSecondsDouble | ||
| float | ServerWorldTimeSecondsDelta | The difference from the local world's TimeSeconds and the server world's TimeSeconds. | |
| float | ServerWorldTimeSecondsUpdateFrequency | Frequency that the server updates the replicated TimeSeconds from the world. | |
| TSubclassOf< ASpectatorPawn > | SpectatorClass | Class used by spectators, assigned by GameModeBase. | |
| double | SumServerWorldTimeSecondsDelta | Cumulative sum of computed server world time deltas for smoothed-averaging | |
| FTimerHandle | TimerHandle_UpdateServerTimeSeconds | Handle for efficient management of the UpdateServerTimeSeconds timer |
Constructors
| Type | Name | Description | |
|---|---|---|---|
AGameStateBase
(
const FObjectInitializer& ObjectInitializer |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | AddPlayerState
(
APlayerState* PlayerState |
Add PlayerState to the PlayerArray | |
| void | AsyncPackageLoaded
(
UObject* Package |
Allow game states to react to asset packages being loaded asynchronously | |
| const AGameModeBase * | Helper to return the default object of the GameModeBase class corresponding to this GameState. | ||
| const T * | Helper template to returns the GameModeBase default object cast to the right type | ||
| float | GetPlayerRespawnDelay
(
AController* Controller |
Returns how much time needs to be spent before a player can respawn | |
| float | GetPlayerStartTime
(
AController* Controller |
Returns the time that should be used as when a player started | |
| APlayerState * | GetPlayerStateFromUniqueNetId
(
const FUniqueNetIdWrapper& InPlayerId |
Returns the player state for a specified unique player Id | |
| double | Returns the simulated TimeSeconds on the server, will be synchronized on client and server | ||
| void | Called by game mode to set the started play bool | ||
| bool | HasBegunPlay () |
Returns true if the world has started play (called BeginPlay on actors) | |
| bool | Returns true if the match can be considered ended. Defaults to false. | ||
| bool | Returns true if the world has started match (called MatchStarted callbacks) | ||
| void | GameModeBase class notification callback. | ||
| void | By default calls BeginPlay and StartMatch | ||
| void | Allows clients to calculate ServerWorldTimeSecondsDelta | ||
| void | Allows clients to calculate ServerWorldTimeSecondsDelta | ||
| void | Callback when we receive the spectator class | ||
| void | Called when the GameClass property is set (at startup for the server, after the variable has been replicated on clients) | ||
| void | Called when the SpectatorClass property is set (at startup for the server, after the variable has been replicated on clients) | ||
| void | RemovePlayerState
(
APlayerState* PlayerState |
Remove PlayerState from the PlayerArray. | |
| void | SeamlessTravelTransitionCheckpoint
(
bool bToTransitionMap |
Called during seamless travel transition twice (once when the transition map is loaded, once when destination map is loaded) | |
| void | Called periodically to update ReplicatedWorldTimeSecondsDouble |
Overridden from AActor
| Type | Name | Description | |
|---|---|---|---|
| void | Allow actors to initialize themselves on the C++ side after all of their components have been initialized, only called during gameplay |
Overridden from UObject
| Type | Name | Description | |
|---|---|---|---|
| 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 |