Seed using in multiplayer game to generate procedural level/enemies

Hi folks,
I need your help. I would like to spawn a random order of enemys for each player in the lobby. However, this order must be the same for every player. That’s why I thought it would be best to pass on a seed to all players via the server and randomly create the order with this seed on the client at the start of the game.
This way I would have a random enemy order for all players and for each new game, but it would be the same for everyone in the lobby.
Since I have several scripts where I use random, I would make the methods async and wait until the methods are ready. So that one script doesn’t accidentally finish faster and slip before the other, resulting in different random results. Is that the best way to do it? Or should I just let the server generate the list at the beginning and then distribute it to all players?

Kind regards

The server sends the seed to clients.

Clients use Random in the exact same order for the exact same thing with the same value ranges throughout. Then you have determinism. However. since UnityEngine.Random is static and you never know what other methods (including 3rd party assets) may be calling Random it‘s best to rely on Unity.Mathematics‘ package version of the instantiable random struct: Struct Random | Package Manager UI website

1 Like

Perfect, thanks a lot for you fast reply/solution.