Hey guys,
so I am using Unity Netcode and Addressables for loading parts of the map. So by starting the game it loads from the main menu the GamePlay Scene where player clones and so on are spawned and the first part of the map additionally via addressables. But the problem is that I think the SceneManager from the NetworkManager tries to sync the scene as I get the error that the location scene isn’t added to the build settings. As I am trying to load the Map parts locally and independent from the host, I don’t want to sync it. So my question is, is there a way to do this? So my location scene is basically only a plane(for testing).
To load a synchronized scene:
NetworkManager.Singleton.SceneManager.LoadScene(..)
To load a non-synchronized scene:
UnityEngine.SceneManager.LoadScene(…)
I use the latter to load the UI scene additively for clients. A scene loaded via UnityEngine.SceneManager cannot contain any network synchronized objects.
Any scene you load needs to be in the build list. It’s just that Netcode warns you about this right away, but for non-networked scenes not in the build list these just won’t load in a build because they don’t exist in the build.
Btw, when you load the map only on clients you’d have to ensure that this map is precisely the same for every client and that every client is authoritative when it comes to interacting (most likely: colliding) with the map. You also cannot synchronize anything in that map, for example if there are items placed in the map then every client gets to pick up that item, it cannot be a networked item.
Why do you not want to sync the map?
Thank you really much for your quick and detailed response. So I am using Addressables to load the map and have no NetworkObject in that scene but it says in runtime that I have to add it to the build list.
So I want to load the map dynamically, meaning it depends where the individual player is. So that the whole map doesn’t need to be loaded. So it would be cool, when the map is synced, but then I would need Custom Scene Management, right? Actually I tried that one but Syncing of Scenes are my problem. I can do Scene Loading and Unloading in Custom Scene Management but I don’t really understand the docs about Syncing the Scenes properly.
Oh, I see, the scene is in the addressable. I overlooked that.
There’s an issue on GitHub for this. Loading scenes from addressables is not implemented but a user shared a script that is supposed to do that further down in the comments.
This is the forum thread about addressables scene loading .
So everyone wanna doing the same:
Just Disable Scene Management on NetworkManager and let all Scenes load you want on Host/Server and Client Side. The Player will spawn normally and for the Sync of prefabs, I recommend checking this out: Custom Scene Management | Unity Multiplayer Networking. So basically you have to do override the Hash from the NetworkObject for every inScenePlaced Prefab, but thats really it. Hope I can help with that. If somebody has further questions, feel free to ask.
Hello everyone, I’ve been checking whatever thread/forum I can find on this issue. In my project I’m using NGO In-Scene NetworkObjects + Addressable scenes. My NetworkObjects are not spawning, and from what I can gather I need to turn-off SceneManagement in NetworkManager and handle it with a Custom Scene Manager. However as someone with no experience coding a Custom Scene Manager, I’m having a hard time doing this. If there are any links to useful documentation, guides or sample codes that you can point me towards I would really appreciate it!
Hi @Alpacalious
Currently, the Netcode for GameObjects integrated scene management does not support Addressable Scenes… it does support addressable prefabs.
Hello,
although I don’t use Unity anymore because they just did some weird decisions and abandoned important tech for more quality projects. I remember that this problem was a relative easy fix. Just turn on custom scene management. So what the built in scene management does is sync alle the scenes. When using addressables what you typically do is having more than one scene. The management scenes etc can be just loaded locally because there is no need to sync, so just implement it like it is a single player game. If you think about it there are really only a few situations where you need synced scenes. And for that parts, for instance when starting the game from a lobby, you just get an api call to the client and then the client handles which scenes to load for that situation. As far as I can remember I solved this(api calls) by using the Lobby UGS Service which provided a way to send messages over clients and then added a listener to the event (a message has a string with the state what happened, for example „Start Game“ and then you manually load this scenes like it was a single player game). Perhaps you can just use Networkvariables to sync the current state(which is „Game“ or „Lobby Screen“ or whatever you need)