Newbie here. I don't get it. In the online strategy game we're trying to make, the player plays on a certain map against AI opponents or other players. The server is an authoritative server. So the player data, AI objects, the map itself also exist on the server.
The thing is, its an online game, so more than one player plays the game. This means the server needs to administer multiple play sessions concurrently, processing collisions on multiple autonomous maps, making sure collisions on one player's playing session does not affect collisions on another player's playing session.
Is it even possible at all for Unity to administer multiple scenes?
Although you can try to get things working with merging all active matches in one scene the best way to go is to startup a headless instance for every match going on. You can start instances of your app in batchmode (headless) using the -batchmode flag.
Search for batchmode in forums give more details how to use it and its limitations (you'll need UnityPro for example).
answered Nov 24 '09 at 07:29 AM
You can handle multiple scenes. What you're probably looking for is Application.LoadLevelAdditive, which loads a scene without destroying the objects that are currently loaded already. With this, you can load multiple maps simultanuously.
Of course, for a complete solution, things get a little more involved: What I'm doing in Traces of Illumination is laying out the different levels "spatially" so that when I load all of them at once on the server, they don't intersect. That way, multiple game groups (groups of up to 20 players playing one level) can play simultanuously in different levels. To make it possible for different groups of players play in the same level without interfering with each other, I disable collisions between any objects that belong to different groups.
It is kind of complex (you also need to make sure that network messages only get sent to those players for which they are really relevant) but quite doable in Unity.
answered Nov 23 '09 at 12:02 PM
I've thought about spawning several instances of the server. That's one way to do it. It would scale well too since it can take advantage of multi-core hardware easily without needing multi-threading.
I managed to create some code that spawns a new instance of the program and pass arguments to it. This only works on standalone builds as webplayers can't receive command line arguments.
answered Nov 25 '09 at 01:40 AM