Search Unity

Multiplayer FPS - network timing problems

Discussion in 'Multiplayer' started by Blackvenom, Dec 3, 2019.

  1. Blackvenom

    Blackvenom

    Joined:
    Dec 11, 2014
    Posts:
    1
    Hello together,

    I have ever dreamt of developing an own fps-game which works over network, basically for playing on LAN partys. I started using Unity for singleplayer games, just playing around and get used to unity. After I found the 3-Part Merry-Fragmas Tutorial (see vid on the end) I finally got a starting point for my first multiplayer fps game.

    Its been a while developing now and i stumbled over a lot of problems and this forum was every time a big help to me!
    Now im facing a problem which I need your help, because im not able to solve it by my own.

    Here's the Problem:
    If "Player A" is shooting at "Player B" a hit-animation is played for every hit until B is getting killed, then a death-animation is played. This works correctly with a knife or a handgun (single shooting), because the time between two shots is long enough.
    If Player B is getting shot by an automatic gun, which shoots fast enough, the hit-animation is played, then when B is killed, the death-animation is played and right in the same moment the hit-animation is played again. This appears as the player is gettin hit, tries to die and then again gets hit and doesnt fall to ground.
    So I strategy is to disable all hitboxes on the player as soon as the death-animation is played.
    The problem is that the hit-boxes are getting disables too late, i think its related to networking-lags.

    Maybe theres also another solution for this (like not leaving the death-animation while its played and staying in there which i already tried and failed), im thankfull for every help.

    Here is the death-animation-transition:
    upload_2019-12-3_19-15-9.png

    and heres the hit-animation-transition (which needs to be interrupted by itself):

    upload_2019-12-3_19-16-59.png

    The logic for getting hit and killed is exactly the same as it is in the Merry-Fragmas Tutorial. Nevertheless i have attached the script which handles the player health (PlayerHealth.cs) and the shooting script (PlayerShooting.cs).

    Thanks in advance for your help!

     

    Attached Files:

  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    From a quick look, you're calling PlayerHealth.TakeDamage, which can call player.Die(), before you're calling RpcProcessShotEffects. I'm going to guess that Die() can call some ClientRpc which does a death animation on the clients. This can result in a shot effect being received by the client in a later frame than being told the player died.

    Depending on whether this is Unet with an unordered channel, or what Mirror transport you're using, you might even be receiving these messages out of order anyway. If you're sending these unreliable you might even be missing some important messages which could be complicating the issue especially when the frequency of messages gets higher. If one of the messages was sent reliably but was lost and had to be resent, the delay between processing two messages sent at about the same time could seem quite big.

    One way some FPS games deal with this is to do a lot of this work all on the client side which fired the bullet. This of course isn't ideal since it opens the game up to a lot of hacking, which is coincidentally one reason why hacking in FPS games is so incredibly common.