Search Unity

Sending input over the network, press is somehow arriving faster than release.

Discussion in 'Multiplayer' started by FoxCastz, Jan 9, 2021.

  1. FoxCastz

    FoxCastz

    Joined:
    Jun 18, 2015
    Posts:
    75
    I have these two functions, CmdForward and RpcForward, you can view them here(like 6 lines of code):
    Code (CSharp):
    1. [Command(channel = 3)]
    2.     void CmdForward(int newForward) {
    3.         RpcForward(newForward);
    4.     }
    5.     [ClientRpc(channel = 3)]
    6.     void RpcForward(int newForward) {
    7.         if(!isLocalPlayer) {
    8.             forwardSync = newForward;
    9.             forward = newForward;
    10.         }
    11.     }
    (channel = 3) is set to Unreliable Sequenced When I press W forward is set to 1 on the clients almost instantly, but when I release W which uses the exact same function to set forward to 0, there is a long delay before 0 is set. If I hold forward for around 2 or more seconds before releasing, then the release message is received instantly like the initial send.
     
  2. FoxCastz

    FoxCastz

    Joined:
    Jun 18, 2015
    Posts:
    75
    I've been at this issue for 10+ hours and solved it and am happy I solved it, but upset at how simple the solution was.
    CustomNetworkManager.maxDelay...that is all
     
    BetaMark likes this.
  3. BetaMark

    BetaMark

    Joined:
    Sep 27, 2014
    Posts:
    229
    I googled around for a minute to see why this was happening (for my own education) and I can only see CustomNetworkManager as part of Unity's deprecated UNet. Are you building a new game on top of Unet or is this class also in one of the other frameworks?