#Another scene management question

17 messages · Page 1 of 1 (latest)

unkempt karma
#

I asked a question earlier in another post about additive loading of scenes. I have that all working. Players can spawn in, run between scenes, etc. etc. All good. Now I was wondering if there is a way, along with that, to have instanced scenes. That is, when going through a portal to another scene a player gets its own instance of that scene, where if another player tries to follow them, they also get only an instance of that same scene, and don't see each other/interact with the same instances of things in their respective scenes, and when they leave they go back out to one of the "shared" additive scenes with all the other players? Imagine running into an instanced dungeon in an MMO, or an owner-only hideout in GTAO.

scarlet meteor
#

You have multiple solutions for that.
One Make instances on server not in same position, but different positions and use interest manager to send data to users depending on their position on server. So you can have a lot of stuff. This is simple to understand, not so much friendly for performance. But friendly if you need to have different actions happening at different instances.

If your scene doesnt interactions, you can spawn everyone into same spot, just update interest manager with it to shop only people in stame instance indicator. then server will have same spot but mmultiple people there.

Last one is just create new instance of server and reconect person there, when he leaves close that instance.

burnt epoch
unkempt karma
# burnt epoch Yes this is doable. In the Additive Levels example there is a portal to move pl...

Im not sure I follow what you mean here. If I update that code to first load another scene instance of the dungeon and then move the player there, how will I tell the player which scene instance to move into. Per the unity docs, if you additively load the same scene multiple times, they will all have the same name and it's impossible to find a particular instance. (https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html)

burnt epoch
unkempt karma
#

So update the portal code to in SendPlayerToNewScene do the same (or roughly the same) as AdditiveLeveltsNetworkManager.ServerLoadSubScenes but for one scene, and after he yield grab the scene handle, store it, and then send the SceneMessage?

#

If that's the case isn't there a race-condition where if two people try to enter different instances at the same time you could drop one of the scenes (grab the same handle on the server for both players) and leak a scene?

burnt epoch
#

Unity is single threaded...the Async is somewhat fake

unkempt karma
#

Good point

burnt epoch
#

you only need the scene ref for moving the player to it inside that coroutine

unkempt karma
#

Right in SceneManager.MoveGameObjectToScene, but I would want to hold onto that reference so that when the exit the dungeon I can unload the instance and waste server memory

burnt epoch
#

I agree it's a PITA that AsyncOperation doesn't give a scene reference in the completed event

burnt epoch
#

gameObject.scene

unkempt karma
#

Oh shoot! Good point!

#

That all makes a ton more sense now! Thank you!