[ad_1]
I’m engaged on a multiplayer mission that entails loading into completely different scenes and taking part in some type of mini-game with every other gamers that occur to be within the scene at the moment. These mini-games will include AI that must be managed by a devoted server. Additionally, there’s simulation that should occur in these scenes, even when no participant is at present in a single.
My first concept to take a crack at this was to have my server on startup, load all the scenes within the recreation utilizing LoadSceneMode.Additive This approach, on the server facet, every scene could be in a single place and obtainable to be simulated.
I made a little bit pattern mission with three scenes, a base world, and two different worlds. When the server is began from the Base World scene, it hundreds World1 and World2 into its scene. From my server, I might spawn a dice in World1 by urgent the 1 key, and I might spawn a dice in World2 by urgent the two key.
I used the next code to spawn the dice:
GameObject dice = (GameObject)Instantiate(myPrefab, new Vector3(0, 10, 0), Quaternion.id);
NetworkServer.Spawn(dice);
The downside is, if a dice is spawned in World1, shoppers in World2 nonetheless spawn the dice. In hindsight this is sensible as a result of the documentation for NetworkServer.Spawn states
Spawn the given recreation object on all shoppers that are prepared.
My subsequent concept was that I might designate one participant within the minigame as a psuedo “host” and his machine could be liable for working the AI. However, with this methodology, I actually cant simulate issues happening when no person is within the scene.
Is there a greater approach I ought to go about fixing this downside? How can I create a devoted server which might simulate a number of scenes without delay? Should every scene be dealt with by its personal server? Am I higher off simply attempting to run every part in a single scene?
[ad_2]