Scene Visibility
Scene Visibility offers details of using the "Scene Condition" with the ObserverManager, and how to manage Observers in a Scene.
Last updated
Scene Visibility offers details of using the "Scene Condition" with the ObserverManager, and how to manage Observers in a Scene.
Last updated
You can control if clients become an of gameobjects in a scene that they are in. This is possible if you set your to include a Scene Condition. The Scene Condition ensures that both scene and spawned are only visible to players in the same scene as the object. In most cases you will want to add a component, with a scene condition to your networked objects.
When a client is loading into the game for the first time, the first scene/offline scene loaded is done so by the Unity Scene Manager. This means that clients were not automatically added to the scene when connected. Which also means they do not have visibility of that scene.
Once client connects to a host or server, If you use the PlayerSpawner component FishNet provided on the NetworkManager, there is logic in that component that will add the client to the default scene on the Player Objects spawn.
If you decided not to use the PlayerSpawner Component provided on the NetworkManger in Fishnet, you will have to either have to load a client into a scene using FishNets SceneManager, or call SceneManger.AddOwnerToDefaultScene() on a Object that you gave that client ownership to.
When Loading a scene globally or by connection, the SceneManager will automatically place that connection into the scene.
Once added that client will be able to view all NetworkObjects that are apart of that scene.
You can add Client Connections to Scenes Manually if the scene is already loaded on the client, by using SceneManager.AddConnectionsToScene();
Manually adding and removing client connections is recommended for Power Users only.
When Unloading a scene from a client, the server will automatically remove the client connection from the scene.
You can remove a client manually from a loaded scene, by using SceneManager.RemoveConnectionsFromScene();
If you are the host, and you unload the hosts client from a scene, it will only remove the host from the scene and the hosts client will lose visibility. See Host Behaviour for for more details.