Handling spawning of players from different teams.

We currently have a game which works like this;
Players connect and join lobby. At this point the players are together in a room and are in the same scene with nothing but a GUI showing who is in and they are already arranged into teams.
The master starts the game and all players load the next scene which is a level.
The master assigns spawn points to everyone based on which team they are on (there are red spawns and blue spawns) and caches an event that tells each player to spawn, specifying which spawn point to use. These are cached so that when players join they receive the message - as the master will join first.
The players then instantiate their prefab on the spawn point.

The problem we have with this is that when we then start the next game from the lobby our cached events are still remembered (despite trying to clear it with code) and an extra player prefab is spawned for everyone as it's running through the cached events. Restart three times and everyone has three prefabs each, and so on.

Is there a better approach to handling spawning? Our issue is that we want to communicate with the master who is handling the placement of everyone. If he sends out an uncached spawn event before other players load the scene - they'll miss it - so we're caching it but it's not clearing down.

Perhaps we're missing some really simple, useful PUN technique.
Sign In or Register to comment.