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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

is Unity3d Physics (the 3dphysics, not the 2d) deterministic

Discussion in 'Physics' started by felchs, Feb 5, 2020.

  1. felchs

    felchs

    Joined:
    Jul 16, 2019
    Posts:
    21
    Talking this on 05/JAN/2020:

    I'm doing a pool game, so I'm interested on the determinism of physics.


    The question if the 3d physics of Unity is:

    - Deterministic throughout different platforms (IOS and Android)
    - Run the same floating point through different platforms

    on any of the devices of:

    - IOS
    - Android

    Is the 3d physics deterministic?

    I know the 2d physics of Unity is not deterministic because it uses Box2D, which is not deterministic: https://support.unity3d.com/hc/en-us/articles/360015178512-Determinism-with-2D-Physics

    The only true way to produce a deterministic simulation is by reloading the same Scene on the same machine. It is possible to have a deterministic result on the same machine with 2D Physics if you structure your application appropriately.

    So it is not possible to achieve determinism thgout IOS and Android

    But the 3D physics???
    I've read on this article https://blogs.unity3d.com/pt/2018/11/12/physics-changes-in-unity-2018-3-beta/

    PhysX guarantees the same simulation result when all the inputs are exactly the same.

    have someone had experience with this issue???
    I'm not confident I can achieve the same physics on different platforms;
     
    Last edited: Feb 5, 2020
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,622
    You're taking that literally as it equally applies to Box2D.

    Both Box2D and PhysX are not fully deterministic due to lack of floating point determinism across platforms (CPU, compilers etc).
     
  3. felchs

    felchs

    Joined:
    Jul 16, 2019
    Posts:
    21
    So that post on https://blogs.unity3d.com/pt/2018/11/12/physics-changes-in-unity-2018-3-beta/
    which says that "PhysX guarantees the same simulation result when all the inputs are exactly the same.", is talking about just one platform and CPU?

    I can achieve this kind of determinism in java using strictfp modifier which can do strict floating-point math, reducing precision but for restricting floating-point calculations and ensuring same result on every platform while performing operations in the floating-point variable.

    So this is not possible with Unity physics?

    I'm So disappointed...
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,622
    Actually, it's NOT talking about it and only making the simpler statement of what it says. Beyond what it says is the truth that the same statement cannot be said across different platforms. In short, it's not saying it's deteministic across multiple platforms because well, it doesn't say that hence the title Enhanced determinism. ;)

    Physx had complexities internally which could make difficult to keep it deterministic on the same set-up. nVidia fixed that in Physx and improved that specific situation but doesn't change the wider issue of floating-point because it's beyond its control; same with Box2D, Transforms and well anything that is sensitive to it.

    No and it not only applies to physics but technically anything that is sensitive to differences in floating-point across platforms.

    The DOTS teams are working on solving this in C# but you'll only see those results for that system for things using it like the DOTS physics etc.
     
    Last edited: Feb 5, 2020
  5. felchs

    felchs

    Joined:
    Jul 16, 2019
    Posts:
    21
    It's an irony that this kind of floating point issue was "solved" on java 1.2 with strictfp.
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,622
    The thing is, it looks like you already raised this and had your questions answered previously here: https://forum.unity.com/threads/how...ics-from-unity3d-in-2019.711311/#post-4754390

    Nothing has changed nor will change and as discussed in that thread, far more complex games than pool exist and perform well across a network. It's just not something you'll get for free.

    In the future, you may be able to use the DOTS physics but beyond that, there's no other info I've got.
     
  7. felchs

    felchs

    Joined:
    Jul 16, 2019
    Posts:
    21
    Yes I put that discussion some time ago, I was wondering if something had changed.

    Do you think if I put sync points I can play the physics on different platforms IOS and Android, will it work well?

    Pool is a very simple game, my fear is that if I do a pool cue shot it would play very different from an android App to a IOS app.
     
  8. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,622
    It's not my area of expertise I'm afraid, sorry. I'd continue your discussion on the other thread or maybe raise it again as a specific subject.