Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to know the progress of client spawn in client server mode

Discussion in 'Netcode for GameObjects' started by wangzhouyang, Apr 26, 2023.

  1. wangzhouyang

    wangzhouyang

    Joined:
    Apr 7, 2023
    Posts:
    2
    I am developing a game using the client-server mode. Two clients connect to the server and start to synchronize the objects of the server. How do I know the progress of the synchronization between the two clients?

    Thanks
     
  2. lp_lafb

    lp_lafb

    Unity Technologies

    Joined:
    Sep 21, 2021
    Posts:
    4
    Hi,

    You can register to the OnClientConnected callback from the NetworkManager. This gets invoked when the client finishes connecting.

    If you are using the integrated scene management, you can use the NetworkSceneManager's scene event callbacks as well. For example, OnSynchronize gets invoked when a client begins to synchronize its scenes and NetworkObjects with the server, and OnSynchronizeComplete gets invoked when the client finishes synchronizing its scenes and NetworkObjects.

    See https://docs-multiplayer.unity3d.com/netcode/current/basics/scenemanagement/timing-considerations for more details on the timing of those callbacks
     
  3. wangzhouyang

    wangzhouyang

    Joined:
    Apr 7, 2023
    Posts:
    2
    Thanks!
    The synchronization start and end events you mentioned can solve some problems, but how to display the progress bar in synchronization still cannot be solved.
     
  4. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    In the majority of cases "ready" or "not ready" is sufficient. Unless you're spending excessive amounts of time syncronizing, the amount of time between 'not ready' and 'ready' is quite small.