Search Unity

Question How do I get same physics result?

Discussion in 'Physics for ECS' started by l1keAboss, Mar 13, 2023.

  1. l1keAboss

    l1keAboss

    Joined:
    Apr 17, 2019
    Posts:
    7
    I think new Physics is determind which I need the cross platform same physic result, so I try to convert my project to ECS and use new physic system. And I convert my demo scene which contain some boxes droping from air to floor to see if I can get same result by playing twice, turn out I alway get different result.
    physics version:1.0.0-pre.44

    But when I try in the physics sample download from github, I modify a demoscene with similar set up like in my own project. And I still get different result, (I did get same result once but when I modify the scene to have more boxes it get different result).
    physics version:1.0.0-pre.15

    So my question is can I get same result cross platform by ECS? And how can I make the physics determind if ECS do support this.
     

    Attached Files:

    Last edited: Mar 13, 2023
  2. Volshar

    Volshar

    Joined:
    Mar 14, 2021
    Posts:
    15
    Cross-platform determinism with the Burst Compiler (and therefore UnityPhysics) feature is still missing.

    Please go to https://unity.com/roadmap/unity-platform/dots and find "Burst Determinism" and mark it as "Critical" with a comment so Unity can see that this feature is highly requested. :)
     
    GameFinder likes this.
  3. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    278
    @l1keAboss I couldn't see any difference in your screenshots.
    Can you please provide the two platforms for which you are not seeing determinism? Thanks!

    Also, when playing twice, you might get slight timing offsets because the subscenes are asynchronously streamed in when closed and their content might get received at different frames. When the subscene is opened, the timing should always be the same.
    The timing offset should not change the behavior though.
     
  4. l1keAboss

    l1keAboss

    Joined:
    Apr 17, 2019
    Posts:
    7
    Both at same machine on windows 10, in the third screenshots it dont have difference, but when I modify the scene more, I got different result almost everytime I replay the game in editor. My Unity version is 2022.2.10f1. But I did found that "Burst Determinism" is not done yet, maybe the feature just did not support yet. c154ebbd1379ae59e629021286320bf.png 34f465d297ba8a0437782c9071ee52d.png
     
  5. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    300
    Are the cubes created from a sub scene or do you instantiate them at runtime?

    if you load them from a sub scene, try instead to instantiate them at runtime (with press of a button and have a reset system that you can repeat the test multiple times) and enable synchronous burst compilation.

    if you repeat the test multiple times in the same play mode session does the result still appear non deterministic?
     
  6. l1keAboss

    l1keAboss

    Joined:
    Apr 17, 2019
    Posts:
    7
    My bad, I think it might because I was accidently setting the physics to none instead of unity physics in physics setting(and I disable the whole physics also), I got same result accross editor and different machine right now. I think there might have some differnent in play loader scene open 2b2 than directly play 2b2 scene.Bacause when I play 2b2 scene directly it got different result, but when I use loader scene to open 2b2 scene it got same result.
    And I test on my own project again, the build got same result too!
    I still got question,
    1, How much determinism does Unity Physics offer in the current version? Right now same at windows x64 is good enough for me but it would be great if it can cross-platform.
    2, Does Unity Physics have configurable joint alternative script? I want to make a active ragdoll by using the joint drive. example editer and different machine.png
     
    daniel-holz likes this.
  7. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    278
    It's great to hear that you get the results you expect now.

    Regarding cross-platform compatibility, there can be slight numerical differences due to various factors on different platforms, but the general behavior should be, if not the same, at least similar. I would suggest you to make some tests for your particular case and see if you get a behavior that is sufficiently similar for your particular case.

    Physics simulation is rather sensitive to numerical differences in calculations, which can occur on different platforms under many circumstances. That can also be the case when using different processors. For example some might support different SIMD vector intrinsics (e.g., SSE vs. AVX). In the latter case, intermediate floating point calculations can lead to more or less precise results due to the availability and use of registers with larger bit counts supporting higher floating point precision.

    As for your other question (2), could you please make a new post with the appropriate title so that the community can also benefit from the provided answer? Thanks!
     
  8. l1keAboss

    l1keAboss

    Joined:
    Apr 17, 2019
    Posts:
    7
    Thanks for you explanation, and sure I will make a new post.
     
    daniel-holz likes this.
  9. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    278
    My pleasure. And thank you!