Hi Natalo, thanks for the tip. But I don’t believe that it will help in this case.
I’m also updating the original post with more info on the issue, now that I’ve checked a few more things, and I believe it will make it clear if I elaborate more on the problem a bit more. But I’ll also reply here the main problem, and I don’t believe using InitGameState instead of PreInitializeComponents will help much, since both are dependent on the GameMode, which is not available on the Client side, where my problem actually resides:
The issue is in how my quests states are being handled, and used to setup extra event binding on these quest-dependent actors.
The current quests states are loaded only on the Server when the game starts, and in the GameMode::PreInitializeComponents it sets up the quests into the GameState in a replicated property. Once this is done, the rest of the actors in the game are initialized, and the quest dependent actors, will (during the actor’s begingPlay event) setup some extra event-binding based on the current quests that are loaded and available in this same GameState property, that holds the quests states. And all is ok in the server-side.
The problem I’m having is actually a Race Condition problem in the Client, in which the quest-dependent actors in the Client will try to access the replicated property in the GameState that holds the quests, but at that moment, this replicated property has not been set received by the client, so it access a nullpoint instead of the actual value of the replicated property. And I know that it is replicating properly, and that this is a race condition, because if I make the actors in the client wait a bit before trying to get the replicated property in their own GameState, it works just fine.
So I’ve in theory adding this delay fixes my problem, but it seems like a bad pattern to me, to just add a delay in the client actors code that will wait for a GameState that has all the required properties before continuing it’s own setup (in the beginPlay code).
Does anyone knows a good example of Multiplayer UE4 C++ code that loads save game data into the Game State, and have the client use this replicated GameState property to setup multiple actors’s information(event bindings) based on that?
I keep thinking that maybe there is a different workflow to archieve the same result (ie: on the client side, dynamically bind event to quest-dependent actors based on replicated properties from the GameState). Maybe it’s possible to replicate the Dynamic event binding on the quest-dependent actors that is done in the server side? And since this seems like a common issue, I would like to know if anyone has a good example of this in action, that is, no just the setup of a gamestate/gamemode, but an example that does something to solve this race condition or that uses a different flow so that it doesn’t happen.
PS: Just saw that there is no way to Edit the original post question to add this bunch of new info =/ So just leave them here in this post instead.