GameInstance variables invalid at OnPostLogin... unless delayed?
I'd been trying to chase a bug in my code thinking I was misunderstanding fundemental aspects of replication... but further testing revealed something peculiar about the timing and availability of GameInstance when going into a lobby level and waiting for Event OnPostLogin from the serving player (I think.)
Bear with me, I'm new at this...
I have an inherited GameInstance object that is storing some variables for 3D UI actors. Using getter functions my PlayerController object can find a specific user widget and communicate with it.
I have a GameMode object, properly configured, that OnPostLogin, calls a test event the New Player, set to Run on Client. This event gets the GameInstance (casted) and gets the variable that holds the reference to the 3D UI actor.
Here is the basic chain of BP:
The Print String for GetGameInfoInstance returns a proper display name (the casting occurs in the function), but the following variable get returns invalid. I've tested this with IsValid checks as well.
But if I put even a zero length delay in EITHER the OnPostLogin event or the Test Event as in one of these images:
Then GameInstance variables return as expected.
I just need to know why this is happening? Do I need these arbitrary Delays in my BP functions or am I simply doing this wrong? It's my understanding that GameInstance is persistent across levels, and so I am using it to store access to these client 3D UI actors. Ultimately, these test events are supposed to alert the lobby PlayerController to get its own lobby UI and refresh it from information passed to it from the GameMode. I don't understand why GameInstance variables are defunct for the client side PlayerController at login?
Attempting to be thorough here- the GameInstance variables are valid in the previous room, which is basically during all the core main menu front end loop. It's not until the game launches a listen server room (Lobby) and handles player logins does this... race condition... seem to appear on the GameInstance.
asked Nov 17 '18 at 01:58 AM in Blueprint Scripting
According to this post, 1st player controller loads before gamemode: https://answers.unrealengine.com/questions/218671/what-is-the-loadorder-of-objects.html
This seems to be the reason for my race condition.
answered Nov 21 '18 at 12:29 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here