Navigation
Unreal Engine C++ API Reference > Runtime > Engine > GameFramework
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- AActor
- AInfo
- AGameModeBase
- AGameMode
- AARSharedWorldGameMode
- ANetworkPredictionExtrasGameMode
- AVPGameMode
References
Module | Engine |
Header | /Engine/Source/Runtime/Engine/Classes/GameFramework/GameMode.h |
Include | #include "GameFramework/GameMode.h" |
Syntax
class AGameMode : public AGameModeBase
Remarks
GameMode is a subclass of GameModeBase that behaves like a multiplayer match-based game. It has default behavior for picking spawn points and match state. If you want a simpler base, inherit from GameModeBase instead.
Variables
Type | Name | Description | |
---|---|---|---|
![]() |
uint32: 1 | bDelayedStart | Whether the game should immediately start when the first player logs in. |
![]() |
bool | bHandleDedicatedServerReplays | If true, dedicated servers will record replays when HandleMatchHasStarted/HandleMatchHasStopped is called |
![]() |
TSubclassOf< class ULocalMessage > | EngineMessageClass | Contains strings describing localized game agnostic messages. |
![]() |
TArray< TObjectPtr< class APlayerState > > | InactivePlayerArray | PlayerStates of players who have disconnected from the server (saved in case they reconnect) |
![]() |
float | InactivePlayerStateLifeSpan | Time a playerstate will stick around in an inactive state after a player logout |
![]() |
FName | MatchState | What match state we are currently in |
![]() |
int32 | MaxInactivePlayers | The maximum number of inactive players before we kick the oldest ones out |
![]() |
float | MinRespawnDelay | Minimum time before player can respawn after dying. |
![]() |
int32 | NumBots | Number of non-human players (AI controlled but participating as a player). |
![]() |
int32 | NumPlayers | Current number of human players. |
![]() |
int32 | NumSpectators | Current number of spectators. |
![]() |
int32 | NumTravellingPlayers | Number of players that are still traveling from a previous map |
Constructors
Type | Name | Description | |
---|---|---|---|
![]() |
AGameMode
(
const FObjectInitializer& ObjectInitializer |
Functions
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
void | AbortMatch () |
Report that a match has failed due to unrecoverable error |
![]() ![]() |
void | AddInactivePlayer
(
APlayerState* PlayerState, |
Add PlayerState to the inactive list, remove from the active list |
![]() ![]() |
void | Broadcast a string to all players. | |
![]() ![]() |
void | BroadcastLocalized
(
AActor* Sender, |
Broadcast a localized message to all players. |
![]() ![]() |
void | EndMatch () |
Transition from InProgress to WaitingPostMatch. |
![]() ![]() |
bool | FindInactivePlayer
(
APlayerController* PC |
Attempt to find and associate an inactive PlayerState with entering PC. |
![]() ![]() |
FName | Returns the current match state, this is an accessor to protect the state machine flow | |
![]() ![]() |
FString | Get local address | |
![]() ![]() |
bool | Return true if we want to travel_absolute, used by RestartGame by default | |
![]() ![]() |
void | HandleDisconnect
(
UWorld* InWorld, |
Handles when a player is disconnected, before the session does |
![]() ![]() |
void | Called when the match transitions to LeavingMap | |
![]() ![]() |
void | Called when the match transitions to Aborted | |
![]() ![]() |
void | Called when the map transitions to WaitingPostMatch | |
![]() ![]() |
void | Called when the state transitions to InProgress | |
![]() ![]() |
void | Called when the state transitions to WaitingToStart | |
![]() ![]() |
void | HandleStartingNewPlayer_Implementation
(
APlayerController* NewPlayer |
|
![]() ![]() ![]() |
bool | Returns true if the match state is InProgress or other gameplay state | |
![]() |
void | K2_OnSetMatchState
(
FName NewState |
Implementable event to respond to match state changes |
![]() ![]() |
void | NotifyPendingConnectionLost
(
const FUniqueNetIdRepl& ConnectionUniqueId |
Called when a connection closes before getting to PostLogin() |
![]() ![]() |
void | Overridable virtual function to dispatch the appropriate transition functions before GameState and Blueprints get SetMatchState calls. | |
![]() ![]() |
void | OverridePlayerState
(
APlayerController* PC, |
Override PC's PlayerState with the values in OldPlayerState as part of the inactive player handling |
![]() ![]() |
bool | PlayerCanRestart_Implementation
(
APlayerController* Player |
|
![]() |
void | Will remove the controller from the correct count then add them to the spectator count. | |
![]() ![]() |
void | Called from CommitMapChange after unloading previous level and loading new level+sublevels. | |
![]() ![]() |
void | PreCommitMapChange
(
const FString& PreviousMapName, |
Called from CommitMapChange before unloading previous level. Used for asynchronous level streaming |
![]() |
bool | Returns true if ready to End Match. Games should override this | |
![]() |
bool | Returns true if ready to Start Match. Games should override this | |
![]() |
void | Removes the passed in player controller from the correct count for player/spectator/tranistioning | |
![]() ![]() |
void | RestartGame () |
Restart the game, by default travel to the current map |
![]() ![]() |
void | Exec command to broadcast a string to all players | |
![]() ![]() |
void | SetMatchState
(
FName NewState |
Updates the match state and calls the appropriate transition functions |
![]() ![]() |
void | SetViewTarget of player control on server change | |
![]() ![]() |
void | StartMatch () |
Transition from WaitingToStart to InProgress. |
Overridden from AGameModeBase
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
bool | CanServerTravel
(
const FString& URL, |
Returns true if allowed to server travel |
![]() ![]() |
int32 | Returns number of active human players, excluding spectators | |
![]() ![]() |
int32 | Returns number of human players currently spectating | |
![]() ![]() |
void | Handles reinitializing players that remained through a seamless level transition called from C++ for players that finished loading after the server | |
![]() ![]() ![]() |
bool | Returns true if the match state is WaitingPostMatch or later | |
![]() ![]() ![]() |
bool | Returns true if the match start callbacks have been called | |
![]() ![]() |
void | Initialize the game. | |
![]() ![]() |
void | InitSeamlessTravelPlayer
(
AController* NewController |
Handles initializing a seamless travel player, handles logic similar to InitNewPlayer |
![]() ![]() |
bool | Returns true if replays will start/stop during gameplay starting/stopping | |
![]() ![]() |
void | Logout
(
AController* Exiting |
Called when a Controller with a PlayerState leaves the game or is destroyed |
![]() ![]() |
void | PostLogin
(
APlayerController* NewPlayer |
Called after a successful login. |
![]() ![]() |
void | Called after a seamless level transition has been completed on the new GameMode. | |
![]() ![]() |
bool | SpawnPlayerFromSimulate
(
const FVector& NewLocation, |
Used in the editor to spawn a PIE player after the game has already started |
![]() ![]() |
void | StartPlay () |
Transitions to calls BeginPlay on actors. |
![]() ![]() |
void | Start the transition out of the current map. |
Overridden from AActor
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
void | Tick
(
float DeltaSeconds |
Function called every frame on this Actor. |