Multiple Concurrent Scenes

Good Evening All,

I am working on a multi-player project, and I am thinking of using Netcode for ECS. I have built a few Unity single player projects, but this is my first multi-player attempt. So, before I get too far into this, I wanted to get the opinion of the team if this would even work.

Scenario: Imagine an escape room game but with multiple different escape rooms (15 scenes potentially in use concurrently). Now if I am being truthful, I doubt this game ever sees the light of day, but I would like to have the possibility of 200 concurrent users with a dedicated server connected to a mysql server. In reality friends and family will probably never get above 75.

The question I have is can that work with unity and Netcode for ECS? Or would you suggest a better mechanism? Or is it a failed experiment before I even start.

Mostly this is an excuse for me to learn the multiplayer side of game design.

Regards,
Masoric

Eh… the more I read on this I’m guessing I am going to have to write some kind of custom back i am guessing?

Hey Masoric,

200 concurrent players in a single server is achievable with Netcode for Entities, and hooking up a custom MySQL backend for persistence is absolutely viable.

Netcode for Entities will help you:

  • Write your gameplay code in a multiplayer-supported way (via DOTS i.e. Entities (an ECS architecture)).
  • Replicate your 200 players in a CPU and bandwidth efficient way. (Burst, Job System, Entities).
  • Give your character controllers client prediction, so input handling is snappy.
  • Give you server-authority i.e. anti-cheat.

But yes, you’d need to write your own persistence via MySQL. The simplest idea is to simply blit the entire ECS world to a file, then save that in your DB, and restore from it. This is trivial, but onboarding into DOTS in general is not (necessarily).

Thank you, I appreciate the response. I am glad to hear that all those functions are in line with what I was reading, and I would much prefer to utilize what is built in then try and write my own back end. My larger concern, however, is the multiple zones or scenes running currently.

Imagine if you have three scenes. A Home or lobby zone scene. Two is a flying puzzle scene, and three is an underground scene. Taken individually, from what I have read it seems like a simple process (as far as these things go) to make it work using those systems.

However, let’s say 50 people spawn in the lobby, 10 of them want to move to the flying scene, 10 of them stay in the lobby, and the remaining 30 people want to move to the underground scene. The question is two fold.

  1. Does unity even natively allow multiple scenes to remain open at the same time?
  2. If the answer to question 1 is yes then the follow up question is can Netcode for Entities work in that environment?

Regards,
Masoric.

  1. You can open as many scene you want via additive loading (and all stay in memory). The question I have in this case is actually: are you talking about Scene or SubScene (I suppose the first). For sub-scene you can load as many you want at any time too.
  2. Netcode for Entities does not provide any Scene synchronisation by default. For that simple reason: we don’t know what you want to do and the risk was to over-engineer the feature. So, from a multi-scene scenario, it is up to the user to devise their own method to track what scene need to loaded (for example by sending RPCs) by the different clients.

The real problem with multiple scene are eventually how to handle the fact the server will load all prefabs for these scene and pretends all clients does the same (even though they may not want to load Scene A or B but only C).

This is the real current limitation and for this the solution (that is also limiting) is to have the ghosts prefab all loaded from the a single shared scene all clients must load.
That would solve the issue and then each individual client can load the scene they want,

In case there are multiple server (one for each scene) the problem is completely different.

If we are then speaking about the simulation itself and how to handle the fact the clients are in different and disjoint “simulation area”, this is a way different different problem to solve.

On solution is to simulate “per-scene” (or better sub-scene) by adding a tag filter in the query to retrieve only the entity belonging to these worlds (that would require all entities being tagged). You can already use the Scene component for that purpose, but I do understand it is not really the best or greatest solution ever.
The problem is that you want to simulate game in different area of the map or the world but within the same server, that has only one world (ECS data) but different “sub-contexts”. And that is not handled.

Another possible solution, more flexible but that requires a lot more of exploration, is to use multiple server worlds, one per scene. In that case there data segragation of them already provide the necessary machinery to segregate the players and the level. However, how to organise the world, connect the player to them etc is all up to the user.
We don’t have much of a sample for that too.

1 Like

I appreciate the very detailed response. I am thinking I am likely going to have to go the route of the second option. Will have to do some investigation on the best way to work that out.

Regards,
Adam