Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question How to postpone fusion initialization until server is ready.

Discussion in 'Game Server Hosting' started by krzyszpieta, Feb 17, 2023.

  1. krzyszpieta

    krzyszpieta

    Joined:
    Jun 14, 2020
    Posts:
    12
    I am having problems with Multiplay and Fusion. So in general everything works like a charm. But I am lost in one particular thing. The flow runs as this:
    1. Client request MM for matchId.
    2. Unity MM successfully starts the server. The server initializes itself.
    3. On the server, I am using the OnAllocated callback, to execute fusion Runner.StartGame() method.
    4. The client in the meantime receives matchId from the MM, and runs fusion runner.StartGame() method

    Problem: The server instance of the Fusion initialization has not yet been completed on the server, while the client tries to initialize Fusion, thus client will never find a game. What am I missing? How to postpone a little bit of fusion initialization on clients. I want to make sure that client will call fusion Runner.StartGame() right after the server runner completes its initialization.

    My entire flow is based on BR2000 and I haven't noticed any postpone mechanism :/
     
  2. MidnightGameDeveloper

    MidnightGameDeveloper

    Joined:
    Apr 26, 2014
    Posts:
    117
    Just wait for 3 seconds by using a coroutine.
     
  3. krzyszpieta

    krzyszpieta

    Joined:
    Jun 14, 2020
    Posts:
    12
    Yup, I did that and it works like a charm. However, we all know that this is bad practice :/
     
  4. unity_03BA514BAC145D0E9AB3

    unity_03BA514BAC145D0E9AB3

    Joined:
    Feb 18, 2023
    Posts:
    7
    Do you use matchId as session same? I made client to look for sessions with the same matchId then call StartGame when it found.