Hi, we’ve been making a multiplayer game and recently encountered difficulty with trying to run code once all players have fully loaded in. Is there a way to do this in Unreal Engine easily?
Define “Loaded in”.
Fully loaded the level, have controller and possessed character, or have joined the server? These are very different things.
Fully loaded level, character and controller relies on the individual hardware and connection of each player. You’d want to call an RPC from Controller upto the server, then to Either GameState or Game Mode notifying that “this” player is ready. Once all players are “Ready”, then do your thing.
Apologies for the late response,
I saw in another post you answered that you created a blank pawn and told it to possess the corrct pawn after it had loaded begin play. I then had the correct pawn set a variable on the player state saying it was ready. The problem I encountered is that the code would get all the player states and then check if each player state was ready, however it only got the player states of the Players that we’re already on the correct pawn, so it was always activating on each players join.
The loading pawn calls the controller. Controller RPCs upto it’s authority proxy which has the GM swap out the pawns. Loading Pawn → Character.
This is where you’d update your ready state if going this route.
Ready players (int) increment. If ready players = max players… Start game.
No need for player state vars etc in this setup. Server knows the player is ready because it just possessed the character class.
As a buffer, when (ready=max), you can either run a delay or timer(better) for 2-3 seconds then start. This should be enough time to account for pings, processing and packetloss resends. Adjust as needed.
Thank you, this works perfectly!!