WaitForPlayersTimeRemaining
WaitForPlayersTimeRemaining
#Overview
name: WaitForPlayersTimeRemaining
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of WaitForPlayersTimeRemaining is to manage the countdown timer for waiting for players to join a lobby before starting the game. This variable is part of the lobby system in Unreal Engine 5, specifically within the OnlineFramework plugin.
This setting variable is primarily used by the Lobby subsystem, which is part of the OnlineFramework plugin in Unreal Engine 5. It’s specifically utilized within the ALobbyBeaconState class, which manages the state of a game lobby.
The value of this variable is set in several places:
- It’s initialized to 0.0f in the ALobbyBeaconState constructor.
- It’s reset to 0.0f in the PostInitProperties function.
- It’s set to the default object’s value when StartWaiting is called.
- It’s set to 0.0f when StartLobby is called.
This variable interacts with other variables and functions within the ALobbyBeaconState class, such as bLobbyStarted and LastTickTime. It’s also used in conjunction with the bRequireFullLobby flag to determine when to start the lobby.
Developers must be aware that:
- This variable is replicated, meaning it’s synchronized across the network for all connected clients.
- It’s used in a tick function (OnPreLobbyStartedTickInternal) to countdown the time remaining.
- When it reaches 0, it triggers the StartLobby function.
Best practices when using this variable include:
- Ensure that the initial value set in the default object is appropriate for your game’s needs.
- Be cautious when manually modifying this value, as it could unexpectedly start or delay the lobby.
- Consider the interaction between this timer and the bRequireFullLobby flag when designing your lobby system.
- Use the OnRep_WaitForPlayersTimeRemaining function to handle any UI updates or game logic that should occur when this value changes.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseGame.ini:64, section: [/Script/Lobby.LobbyBeaconState]
- INI Section:
/Script/Lobby.LobbyBeaconState
- Raw value:
20.0
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/Lobby/Private/LobbyBeaconState.cpp:136
Scope (from outer to inner):
file
function ALobbyBeaconState::ALobbyBeaconState
Source code excerpt:
LastTickTime(0.0),
bLobbyStarted(false),
WaitForPlayersTimeRemaining(0.0f)
{
bReplicates = true;
bAlwaysRelevant = true;
NetDriverName = NAME_BeaconNetDriver;
LobbyBeaconPlayerStateClass = ALobbyBeaconPlayerState::StaticClass();
#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/Lobby/Private/LobbyBeaconState.cpp:156
Scope (from outer to inner):
file
function void ALobbyBeaconState::PostInitProperties
Source code excerpt:
{
// Set instances back to 0, it will be set in StartWaiting
WaitForPlayersTimeRemaining = 0.0f;
}
}
void ALobbyBeaconState::PostInitializeComponents()
{
Super::PostInitializeComponents();
#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/Lobby/Private/LobbyBeaconState.cpp:185
Scope (from outer to inner):
file
function void ALobbyBeaconState::GetLifetimeReplicatedProps
Source code excerpt:
DOREPLIFETIME(ALobbyBeaconState, Players);
DOREPLIFETIME(ALobbyBeaconState, bLobbyStarted);
DOREPLIFETIME(ALobbyBeaconState, WaitForPlayersTimeRemaining);
}
void ALobbyBeaconState::StartWaiting()
{
if (GetLocalRole() == ROLE_Authority)
{
WaitForPlayersTimeRemaining = GetClass()->GetDefaultObject<ALobbyBeaconState>()->WaitForPlayersTimeRemaining;
OnRep_WaitForPlayersTimeRemaining();
LastTickTime = FPlatformTime::Seconds();
}
}
#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/Lobby/Private/LobbyBeaconState.cpp:203
Scope (from outer to inner):
file
function void ALobbyBeaconState::StartLobby
Source code excerpt:
if (GetLocalRole() == ROLE_Authority)
{
WaitForPlayersTimeRemaining = 0.0f;
OnRep_WaitForPlayersTimeRemaining();
LastTickTime = FPlatformTime::Seconds();
bLobbyStarted = true;
OnRep_LobbyStarted();
#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/Lobby/Private/LobbyBeaconState.cpp:256
Scope (from outer to inner):
file
function void ALobbyBeaconState::OnPreLobbyStartedTickInternal
Source code excerpt:
// If a full game is required, don't even worry about the timer. It has to be allowed to go indefinitely until the game is
// full, at which point the lobby will be started automatically.
if (!bRequireFullLobby && WaitForPlayersTimeRemaining > 0.0f)
{
WaitForPlayersTimeRemaining -= DeltaTime;
if (WaitForPlayersTimeRemaining <= 0.0f)
{
WaitForPlayersTimeRemaining = 0.0f;
StartLobby();
}
}
}
void ALobbyBeaconState::OnPostLobbyStartedTickInternal(double DeltaTime)
#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/Lobby/Public/LobbyBeaconState.h:293
Scope (from outer to inner):
file
class class ALobbyBeaconState : public AInfo
Source code excerpt:
/** Amount of time waiting for other players before starting the lobby */
UPROPERTY(config, ReplicatedUsing = OnRep_WaitForPlayersTimeRemaining)
float WaitForPlayersTimeRemaining;
/** Array of players currently in the game, lobby or otherwise */
UPROPERTY(Replicated)
FLobbyPlayerStateInfoArray Players;
/** Handle the lobby starting */