Hello
I’m seeking advice on the correct methodology for updating a flag in my ALobbyGameMode from a widget, particularly when dealing with scenarios like manual session creation. Here’s a detailed breakdown:
Context:
Within Unreal Engine, I’ve implemented a bGameLogicActive
flag in my ALobbyGameMode that dictates whether specific game logic, especially PostLogin
functionality, should be active.
*I need to dynamically adjust this flag from my UGameMainMenu
widget, especially when creating a session manually.
Current Implementation:
In UGameMainMenu, I have a method called ToggleGameLogicActive(bool bActive) tasked with toggling the value of bGameLogicActive in ALobbyGameMode.
void UGameMainMenu::ToggleGameLogicActive(bool bActive)
{
ALobbyGameMode* LobbyGameMode = GetLobbyGameMode(); // Assuming you have a method to obtain the reference to ALobbyGameMode
if (LobbyGameMode)
{
LobbyGameMode->ToggleGameLogicActive(bActive);
}
}
In ALobbyGameMode , the ToggleGameLogicActive function sets bGameLogicActive`accordingly.
void ALobbyGameMode::ToggleGameLogicActive(bool bActive)
{
bGameLogicActive = bActive;
GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Green, FString::Printf(TEXT("bGameLogicActive set to %s"), bActive ? TEXT("True") : TEXT("False")));
}
Question:
*What is the recommended and best practice for updating a flag in ALobbyGameMode from a widget, specifically when managing scenarios like manually creating a session in UGameMainMenu? My goal is to activate PostLogin
based on the value of a flag.
Current Challenge:
- When I manually create a session and attempt to set bGameLogicActive to
true
, it doesn’t seem to trigger the expected behavior in PostLogin.
I would greatly appreciate any insights, recommended practices, or examples that can help me efficiently handle this situation.
Thank you for your expertise!