Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Havok Physics multiplayer limitations

Discussion in 'Multiplayer Dev Blitz Day 2023 - Q&A' started by Spikee_wave, Jul 20, 2023.

  1. Spikee_wave

    Spikee_wave

    Joined:
    Feb 27, 2018
    Posts:
    5
    TL;DR
    When making a multiplayer physics game, what things CAN NOT be done with a Havok Physics that CAN be done with Unity Physics and why?


    When comparing Unity Physics and Havok Physics it is stated that Havok is not the best choice for the multiplayer games because it is statefull. But there is a need for a stable physics simulation that can be provided by Havok Physics when making a multiplayer physics-based games. (ex. multiplayer sandbox physics game similar to space engineers or scrap mechanic).
    As I understand for now, the problem is that with the Havok Physics there is an internal physics engine state that is problematic (?) to sync across the clients. And for now I don't see a way to extract that state to perform a physics simulation rollback with custom code and also I don't see that it is handled automatically somehow. The state is a data and a data can be send across the network. Maybe this data is costly to send through the network but this is a not valid argument to not allow doing this at all.
    My question: making a multiplayer physics game, what things can not be done with a Havok Physics that can be done with Unity Physics and why?
     
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    774
    Havok Physics is not deterministic in case rollback and re-simulate. That pose several problem in term of predictability of the simulation. Unity Physics bteing stateless has instead that guarantee.
    Why netcode for entities (that has a server autnoritative model, with client-prediction) does not require full determinism, having deterministic (or close to it) physics simulation is important to avoid tons of mis-prediction.
    There are also other implication, like performance impact (because caches are invalidated) potentially also "precision" and stability may be impacted (because contact caching and manifolds need to be re-created).
    Unity.Physics, again because of stateless nature, is indeed less "stable" for large stacking, but has more coherent performance and overall controllable behaviour.
     
  3. Spikee_wave

    Spikee_wave

    Joined:
    Feb 27, 2018
    Posts:
    5
    Thanks for an answer :) One more question.

    What kind of determinism is achieved with Unity Physics? I think about floating point math non-determinism.
     
  4. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    774
    The simulation is deterministic given a CPU architecture (this is also true for Havok). The difference being, because no cache are involved, restarting the simulation from frame X, with the sole velocity and transform (That is the state of the physic system), give 100% the same results.
    With Havok, it is possible this determinism is not guaranteed, because of the caching and other internal details.