Search Unity

Significant delay on client when using Relay with Unity Transport (even with small data)

Discussion in 'Netcode for GameObjects' started by Filip8429, Apr 1, 2022.

  1. Filip8429

    Filip8429

    Joined:
    Dec 16, 2018
    Posts:
    20
    I followed some tutorials and created a character controller with Server-Authoritive Input. Even sending a single ServerRPC-request with only a float, there was a delay of almost an entire second.
    I tried creating a Character-Mover by having two NetworkVariables for position and rotation (tried it with two verctor2s and even 4 floats). The PlayerInput was processed by a ServerRPC-request. On the host, there is no significant delay, but on the clients it's unplayable. Even when clicking a button, there is a long delay.

    Is this because of the Servers still being free and in beta, or is something in my code wrong? I found out that even Dilmars project has this long delay. Here is his code, which is pretty similar to mine:

    https://github.com/dilmerv/UnityMultiplayerPlayground/blob/master/Assets/Scripts/PlayerControl.cs
     
    Oberheim likes this.
  2. Oberheim

    Oberheim

    Joined:
    Jun 4, 2020
    Posts:
    24
    Hey ! Have you found a solution for this ? Experiencing the exact problem with the same content. Followed dilmer tutorial but same thing happen :(
     
  3. CreativeChris

    CreativeChris

    Unity Technologies

    Joined:
    Jun 7, 2010
    Posts:
    457
  4. itisMarcii_

    itisMarcii_

    Joined:
    Apr 5, 2022
    Posts:
    111
    If you want to have instant feedback, like in a singleplayer game (offline game), you need a Client/Input Prediction. Because of the RTT (RoundTripTime) it takes for the message to be delivered from Client to Server back to Client.
    The larger the physical distance of the Server and the Client, the larger the RTT.

    Also, if you are using the NetworkTransfrom and the Interpolation, you need to keep in mind that the Interpolation buffers a few incoming Inputs before processing it. This also causes delay.



    A Client/Input Prediction is a very difficult task, espacially with Unity since its not deterministic with its Updates.

    PS: The Netcode Roadmap has the Cliend-side Prediction planned.

    upload_2022-9-29_14-5-27.png