Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Initial synchronization Scene Event Notification is not sent when starting a host

Discussion in 'Netcode for GameObjects' started by neviovalsa, Aug 29, 2023.

  1. neviovalsa

    neviovalsa

    Joined:
    Jun 24, 2019
    Posts:
    33
    Version 1.5.1 and 1.5.2

    When starting a host, I'd expect to receive a `SceneEventType.SynchronizeComplete` event when all in scene placed networkObject get spawned, and I never receive the event.

    My code follows pretty much what described in the docs:

    Code (CSharp):
    1.  
    2.                 RelayServerData relayServerData = new RelayServerData(allocation, "dtls");
    3.                 NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(relayServerData);
    4.                 NetworkManager.Singleton.ConnectionApprovalCallback = ApprovalCheck;
    5.                 NetworkManager.Singleton.NetworkConfig.ConnectionData = System.Text.Encoding.ASCII.GetBytes(LobbyManager.Instance.CurrentPlayer.Id);
    6.                 bool success = NetworkManager.Singleton.StartHost();
    7.                 if (success)
    8.                 {
    9.                     NetworkManager.Singleton.SceneManager.OnSceneEvent += NetworkSceneManager.Instance.SceneManager_OnSceneEvent;
    10.                 }
    In my NetworkSceneManager I reduced the code to a simple log

    Code (CSharp):
    1. public void SceneManager_OnSceneEvent(SceneEvent sceneEvent)
    2.         {
    3.             print("SCENE EVENT");
    4. ...}
    N.B. I do receive the events when a client connects
     
  2. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    175
    Hi there,
    Have you ever tried to add Listener before the "StartHost" method?
     
  3. neviovalsa

    neviovalsa

    Joined:
    Jun 24, 2019
    Posts:
    33
    Hi,
    thanks for the suggestion but I tried and when subscribing to scene events before starting the host makes the call to StartHost throw.