Search Unity

Merry Fragmas 3.0 UNet Multiplayer server client delay problem.

Discussion in 'UNet' started by AbhinayNegi, Feb 10, 2019.

  1. AbhinayNegi

    AbhinayNegi

    Joined:
    Dec 22, 2017
    Posts:
    17
    I followed the Unity tutorial, Merry Fragmas 3.0 by Mike Geig. In this tutorial when we shoot we have to do the calculation on the server and then the result is then sent back to the clients for effects like Muzzle flash and hit effect. But the problem is causes this causes a very noticeable delay on clients. If I press the Fire button it first goes to the server using [Command] then come back to the clients using [ClientRpc]. Is there any way to fix or optimize this problem or Should I do every calculation only on clients?
     
  2. daxiongmao

    daxiongmao

    Joined:
    Feb 2, 2016
    Posts:
    412
    You would typically distinguish between server and client effects.

    So assuming they are not cheating the client should know if the player has bullets and you can just trigger the muzzle flash on the client not having to wait for the server.

    But for a hit result or effect you probably need to wait for the server to respond.
    But it can also be done on the client which should be matching the server.

    You just run the chance of it looking like the player hit something when they did not if server says no.
     
    AbhinayNegi likes this.
  3. AbhinayNegi

    AbhinayNegi

    Joined:
    Dec 22, 2017
    Posts:
    17
    Thanks @daxiongmao I'll try this approach and see what happens.