Questions about allocation and scene manager

Hello there!
Working with Multiplayer for the first time is very difficult for me, it’s very hard to wrap my head around the new concepts and things like what should run on the client and what should run on the server and that kind of stuff, so I apologize in advance if these questions are a bit silly.

  1. What is allocation? In the lecture “Allocating a Relay” Nathan talks about creating an allocation and in fact, that’s the first thing that is done when starting the host on the HostGameManager class, but I’m not sure I understand what are we doing here. To me, allocation sounds like reserving space (reminiscent of memory allocation maybe?) but I’m not sure if I should think about the concept this way.

  2. At the end of the StartHostAsync method we use this line to go to the game scene:
    NetworkManager.Singleton.SceneManager.LoadScene(gameSceneName, LoadSceneMode.Single);
    But in a previous lecture, we used a pretty normal
    SceneManager.LoadScene(MenuSceneName);
    to go from the Netbootstrap scene to the Main Menu scene

So my question is why? and especially when should we use one over the other?

Thanks! This is an excellent course, by the way, Nathan is a great teacher :slight_smile:

3 Likes

Hi there, great questions!

  1. A relay is the intermediary that Unity Gaming Services (UGS) is creating between the clients and the host. Essentially they have a server that relays information from the clients to the host. Since both the client and the host can connect to the UGS server securely, it smooths over creating a connection between the clients and the host (and makes it easy for us). Allocation of the relay, is designating one of the UGS servers to act as a relay. Just like you suggest, some CPU time and memory on one of the servers is being allocated to run this connection between the client and the server. You can see in your UGS dashboard how many servers have are currently allocated to act as relays or dedicated servers.

  2. The SceneManager.LoadScene as you know is used to change scenes. But what if you want all the clients to also change scenes at the exact same time. Behold, the NetworkManager.Singleton.SceneManager.LoadScene!
    Essentially it’s the same function, but it sends a message across the network for all the clients to change scenes as well. In our case, going from the netbootstrap to the main menu occurs before the connection is setup, so we do that normally. After the connection is made, we use the NetworkSceneManager to move everyone to the next scene at the same time.

I think that’s the basic functionality, but the NetworkSceneManager seems to offer more than just synchronized scene changes, check out the documentation here:

4 Likes

Thank you very much!

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms