Can a single simulator run multiple scenes? Suppose the client is in scene 2 while the simulator is running scene 1, will it still be able to sync objects in scene 2?
Scene 2 and it’s corresponding live query will need to be represented somehow on the simulator. What’s your use case here? If you’re wanting one simulator to run multiple “rooms” or session you can take a look at these docs:
Otherwise take a look at scene management here. In the sense of scene mangement your Simulator (if you’re using a normal non multi-room sim) is just like any other client: Scene management | Unity Multiplayer SDK Documentation | coherence
Does this answer your question @codya ?
I meant, suppose if there are two groups of players in the same server: Group A is playing in Scene A, and Group B is playing in Scene B. Will one simulator be enough to simulate NPCs in both scenes?
From our SDK team:
If each of them has a coherencebridge and they use different scene indexes, you can run both scenes off the same simulator and they will operate independantly. This is assuming you will connect to the same room/world. In this scenario you dont need shift coords
So, essentially each client could be in it’s own scene (the coherence bridge in each scene needs to have different scene indexes) and the simulator would need both scenes loaded and it would handle all entities
I assume that the simulator is adding the scenes additively. Will there will be conflicts between the 2 scenes? For example: if at scene “A”, the NPC is spawned at position (0,0,0) while in scene “B”, walls exist in the same position (0,0,0), wouldnt the wall affect the NPC’s movement? Also, suppose the game relies on singletons in the scene, would it still work?
If the same singleton is in both scenes but needs to have different data, no that won’t work.
The key to prevent collisions is that each coherence bridge has a different index and will only sync entities in the same scene. You will need to build your gameplay such that the two objects don’t interact in a Unity sense (physics, racasts, etc).
Alternatively you can “shift” each scene by some amount in coordinate space to make this easier. You still need each coherence bridge to have a separate index, though.
See: Scene management | Unity Multiplayer SDK Documentation | coherence
Each Coherence scene is represented by an integer index. You can map this index to your scenes or levels in any way you find appropriate. Projects that don’t use scenes will implicitly put all their entities into scene 0.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.