chris-gong/gamelift-example-ue4

GameState's PlayerArray variable may not be accessible by the time the GameLiftTutorialWidget is constructed

chris-gong opened this issue · 0 comments

In the GameLiftTutorialWidget class, specifically on this line, the GetWorld()->GetGameState()->PlayerArray variable may not be populated by the time the SetTeammateCount function is called, which gets called right after
the client's UI is created. This makes sense as the GameState may not have finished initializing yet.

Although I'm not sure if I will get to fixing this as the main priority currently at the time of writing this is to work on a completely new example project for Unreal Engine 5, a way around this would either be to add a null pointer check around the variable in that same spot, or invoke SetTeammateCount after BeginPlay is called instead of NativeConstruct. I believe the latter is better because if the if-check fails then your UI will never be populated unless you add more code to address that scenario.