Search Unity

Resolved Scene Management Help

Discussion in 'Netcode for GameObjects' started by jrock75, Dec 4, 2022.

  1. jrock75

    jrock75

    Joined:
    Mar 20, 2021
    Posts:
    4
    I've been struggling for a few days trying to understand scene management for multiplayer. I made the small chart below to show what I'm trying to do, it's similar to most online RPGs. In the Login scene the Network Manager is created on authentication. Then when authenticated the clients are automatedly transferred to the Open World where the server/host is. I want the clients to go to the Character Selection, then to the Open World. Can anyone please provide some insight into how to do this. Searching I either find everyone is in one scene or a lobby at some point all the clients change scenes at the same time.


    Flow.png
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,882
    Clients cannot be in a different scene than the server without writing your own custom scene management.

    For something like this I always recommend to reconsider what a scene is and does. You don't have to have a separate scene for menus such as character selection and creation. This can be done entirely within the world scene by using a UI popover. Alternatively you could still design those screens as scenes but load them additively (non-networked scenes since only a specific player should see them!) and unload them when the screen is closed.

    Most open world games actually design their screens to be overlays over the world and allow for some amount of transparency, any maybe blur everything that's below the UI (GTA does that I believe).

    If the popover is fullscreen with an opaque background, you might consider disabling rendering of the world but that is entirely optional. It would also be tricky because you cannot just set the world root object to inactive while it contains networked objects.

    The alternative would be to redesign the screens into Character Creation & Selection being done offline. For some games these needn't be online at all. The player having created and selected a character from the predefined set of options would only then enter the login screen, connect, and spawn in the world. During connection approval you can pass in a payload that defines the player's character (eg identifiers for head, body, armor or whatever and colors, texture indexes etc).

    However, if this is an MMO game where characters are stored online then the character selection screen at least has to be done online in order to retrieve the persisted characters. But it would work fine for a coop game or where most sessions are played among trusted peers, so as to be able to store player state/progress on each client (including cloud saves like steam offers).

    If it has to be more secure with players only persisted online you could store those characters on the server in a way (database) that you can request their state via UnityWebRequest but that would also require the player to have an account on that server to identify the player. So you'd have to have the account management as a web service (including 3rd party account management services such as facebook, twitter, google etc) to identify players. For large-scale MMOs this is the way to go because you wouldn't want the realtime netcode server also have to deal with account management and all other non-realtime stuff like character creation/selection.
     
  3. jrock75

    jrock75

    Joined:
    Mar 20, 2021
    Posts:
    4
    Thank you for your insightful response.

    As I’m new to game development I don’t think I’m ready to drive into a custom scene manager. I was hoping I could have separate scenes for dungeons and stuff later. I had thought about the UI option and looks like the option I should take.