#How do i check if a scene is changed with Netcode for GameObjects
6 messages · Page 1 of 1 (latest)
public override void OnNetworkSpawn()
{
NetworkManager.Singleton.SceneManager.OnLoadEventCompleted += SceneManager_OnLoadEventCompleted;
NetworkManager.Singleton.SceneManager.OnLoadComplete += Scenemanager_OnComplete;
Debug.Log("Host Completed");
}
now this Method Runs as the Log is being logged but then the other scripts other methods arent running
private void Scenemanager_OnComplete(ulong clientId, string sceneName, LoadSceneMode loadSceneMode)
{
Debug.Log("Check Numero 2");
}
private void SceneManager_OnLoadEventCompleted(string sceneName, UnityEngine.SceneManagement.LoadSceneMode loadSceneMode, System.Collections.Generic.List<ulong> clientsCompleted, System.Collections.Generic.List<ulong> clientsTimedOut)
{
Debug.Log("Check numero 1");
foreach (ulong clientId in NetworkManager.Singleton.ConnectedClientsIds)
{
Debug.Log("Player Prefab Instanciated");
Transform playerTransform = Instantiate(PlayerPrefab);
playerTransform.GetComponent<NetworkObject>().SpawnAsPlayerObject(clientId, true);
}
}
the SceneManager_OnLoadEventCompleted
and
SceneManager_OnCompleted
are same but different
the first one is server side whilst the other is client side