Search Unity

Networked collision?

Discussion in 'Physics for ECS' started by goodnewsjimdotcom, May 26, 2021.

  1. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    342
    Hello,

    If I my server detects a collision and wants to send collision data to a player who ran into a wall, do I just send it's new velocity, angular momentum, and damage.... Or is there more to it?

    ,Jim
     
  2. AlienFreak

    AlienFreak

    Joined:
    Jul 2, 2012
    Posts:
    40
    I would like to know as well. Does the NetCode package handle this?
     
  3. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    342
    I don't even need to know anything about network... Just what does the collision do? Change velocity angular and angular momentum?
     
  4. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Player controllers and networking them is a rather advanced area and far more complex then it might seem.

    Actually I see https://assetstore.unity.com/packages/tools/physics/rival-dots-character-controller-195567 is now out. This is a DOTS physics controller by the author of the best Physx based kinematic controller in Unity. I just grabbed it myself to check out.

    Integrating that with DOTS Netcode might be a good option. Or grab another third party networking solution and then roll your own snapshot interpolation.


    For players the industry standard is kinematic controllers. Dynamics is too dynamic, you need predictable consistent behaviour and kinematic is the only way to get that reliably.

    With kinematic you are moving the player manually basically. You move and then there is an integration step where you solve for collisions. And then you manually adjust the player position so it's not colliding. This gets rather complex with step handling, moving platforms, etc.. The DOTS physics samples have a basic kinematic controller but basic is the key word here.

    So networking is just sending position/rotation and interpolating that on the client. No physics involved client side. The standard is some type of snapshot interpolation to smooth out latency.

    All told there is just no simple solution here and no viable shortcuts you can take that won't result in some pretty bad behavior in real world networked gameplay.
     
    gentmo and Occuros like this.