Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Change scene

Discussion in 'Netcode for GameObjects' started by agnushallard, Aug 7, 2023.

  1. agnushallard

    agnushallard

    Joined:
    Nov 22, 2018
    Posts:
    15
    Studying the netcode, I came across a doubt. I looked on the net and youtube, but I couldn't find it. I don't think I know what to look for. My problem is: if I have three players in the scene. 1 host and 2 clients and I want one of them to change the scene I have to change the host. But when I change it the other 2 go along. So how do I get players to switch scenes whenever they want?

    If you have any video or tutorial or example so I can study. Thanks
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    Perhaps you may not have to change scenes to begin with? You could a) load/unload additive scenes or b) simply enable/disable game objects.

    For example, a common misconception is that if you want one player to go to the main menu or the equipment screen, that you need to have those in a separate scene. But you can just as well implement menu screens by enabling/disabling full screen canvases while disabling game logic for this player in the meantime.

    It's been a while but about half a year ago NGO would not allow you to have some players in other scenes.
     
  3. agnushallard

    agnushallard

    Joined:
    Nov 22, 2018
    Posts:
    15

    how would you recommend me to do for example: I have a street that has a building. So two players decide to enter the building while the other stays outside.
    I'm assuming that for game sake the interior of the building has to be in another scene.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    Depends on how many buildings you have. You could have the interior disabled, and when you enter, enable the interior and possibly disable the exterior environment. Unless there are hundreds of buildings that should be okay to have them all in the same scene.
     
  5. agnushallard

    agnushallard

    Joined:
    Nov 22, 2018
    Posts:
    15

    Ok mate, thanks