Search Unity

Feedback Physics determinism

Discussion in 'Physics for ECS' started by jdtec, Dec 9, 2020.

  1. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    302
    1) Is Unity physics expected to be deterministic given the same inputs on the same device across app runs?

    2) If the answer to 1 is yes, then do you have CI tests in place to validate this?

    Since updating to 0.5.x it appears that this isn't the case anymore (or maybe I was just lucky before). I've seen some entities get different rotation values after a while. They are very very similar but not identical. I'm not sure it's physics but it happens after I manually call the SimulationSystemGroup step.

    UPDATE: I've only repro'd this between editor and standalone so far, which makes me think this probably isn't physics related but some other setting between editor and standalone floating point calculations I need to figure out... Would still be interesting to hear the answers to the above though.
     
    Last edited: Dec 9, 2020
  2. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    1) Yes
    2) We do have quite extensive set of tests to confirm this

    Typical problems with editor vs. standalone are:
    - Burst on/off - if this happens, you'll get different simulation for sure, since with/without Burst ends up with different compilers and therefore different math
    - Synchronous/asynchronous Burst - if Burst kicks in at different times due to it being asynchronous, it will produce different results, as different compiler kicks in at different times
    - Integrity checks - if you are seeing integrity failures from physics, this means you are doing illegal stuff during physics step (adding/removing component data, writing to component data), and this can cause re-order of entities and lead to incorrect physics results.
     
    jdtec likes this.
  3. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    302
    petarmHavok likes this.
  4. wenxuejia

    wenxuejia

    Joined:
    Sep 20, 2018
    Posts:
    4
    Hi, what about the same input on different devices? I wanna make a lock-step game,
    I see someone say this:"Dots will never be deterministic. It's impossible because it is still using floating point." in this page: https://forum.unity.com/threads/deterministic-rollback-lockstep.1017223/
    Can you give me any advice? Thanks a lot~
     
  5. HellGate94

    HellGate94

    Joined:
    Sep 21, 2017
    Posts:
    132
    deterministic on the same machine. but not over the network with different processors since each processor does float math slightly different. that would require software float and thats terrible slow and is super unlikely to happen
     
    wenxuejia likes this.
  6. wenxuejia

    wenxuejia

    Joined:
    Sep 20, 2018
    Posts:
    4
    Thanks~
     
  7. HellGate94

    HellGate94

    Joined:
    Sep 21, 2017
    Posts:
    132