Search Unity

Third Party Collision detection with projectiles across clients Photon 2

Discussion in 'Multiplayer' started by Noxirus, Jul 9, 2020.

  1. Noxirus

    Noxirus

    Joined:
    Sep 18, 2019
    Posts:
    40
    Hello Everyone,

    I am in the process of making a game that involves shooting projectiles at other players using the photon 2 network. While hits do seem to register its not always the greatest at accurately detecting the collision for the player taking the hit.

    I believe the reason for this is the slight delay in communication between client and the other clients causes the projectile to appear to hit the player on the offenders clients but the one getting hit is in a slightly different location.

    I am currently tracking players locations via photon transform view (which may not be the best way to track their exact location?) and the projectiles being fired are not being tracked via transform but considering their behavior is identical across clients the only thing at the moment they are tracking is when the projectile is being activate and its current location.

    Any thoughts on how to make collision detection between clients more accurate? Thanks so much for any feedback you may have.

    Hope you are all staying healthy and safe out there.

    -Noxirus
     
  2. emotitron

    emotitron

    Joined:
    Oct 9, 2016
    Posts:
    41
    Hi Noxirus

    With vanilla Pun2 you will have to code in your own projectile logic for that. You don't want to make your projectiles into net entities (spawned photon views), but rather you want to treat them as events. You can cheat them into the shooters time frame on clients by advancing their movement by RTT (ping) on non-owners.

    The SNS (Simple Network Sync) library I am developing for Exit handles this, if you want to try the beta, or get some ideas from that code. You can find details in the pinned topics in the Simple channel on the Photon Discord server:

    https://discord.gg/egaRfd8

    upload_2020-7-10_7-24-5.png
     
  3. emotitron

    emotitron

    Joined:
    Oct 9, 2016
    Posts:
    41
    Checking out the state of that in the Beta, it isn't wired up full for rigidbodies. So going to wire that up today now that I am looking at it.
     
    digiross likes this.
  4. Noxirus

    Noxirus

    Joined:
    Sep 18, 2019
    Posts:
    40
    Hi Emotitron,

    Thanks so much! I will look into that.

    -Noxirus