So I’ve been making a multiplayer game and everythings been going pretty well until this problem. Im trying to check if all players have loaded in before actually starting the game. This approach is used by many, if not almost all multiplayer games to ensure that code that triggers right as the game starts, triggers for every player. The problem is however, that I havent found a way to do this. My first method was just checking if the number of player characters was equal to the amount of players that were in the pre-game lobby. This however failed and code triggered too early. So im asking, how do I check if every Player is fully loaded in / instantiated before triggering certain code?
You can’t simply use the controller/player count.
When a player joins the GM creates a controller and replicates it to the client. The GM then spawns the default pawn (GM settings) and possesses it with the controller. The pawn and eventually the possession get replicated. This process is not instantaneous, nor is it guaranteed to replicate in the same frame.
How long it takes to get the replicated controller, pawn and load the map is up to client connection and hardware. It varies client to client.
I handle this by creating a custom pawn class and set it as the default pawn in the GM settings. The class is bare bones, no mesh, movement etc. Its only job is to notify the controller (RPC → Server controller) when the map has loaded enough to spawn the game character.
On receival of the notification the controller (server-side) calls an event in the Game mode to spawn the main character, possess it and update player join counts, ready states etc.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.