Why don’t you do it like this. In your game mode override methods on OnPostLogin
, and OnPostLogout
.
You will get PlayerController
from those methods. You can get PlayerState
from it. Store player states in some array in GameState when player joins, and remove it when player LogsOut.
In PlayerState
create replicated boolean variable that will track when player is ready.
In PlayerState
create Event
that is Replicated
→ RunOnServer
. Whenever any of the players is ready, call the method from the clients side.
Now last step, whenever that event is called, make sure to call some method in GameState
. That method in game state should iterate through the whole list of player states, and check if all of them are ready. If they are, do your magic. Please don’t do it on GameState::Tick
method
Please note the difference between the PlayerState
and PlayerController
. Same as with GameMode
, and GameState
.