Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Question What obstacles are there to cross platform determinism?

Discussion in 'Physics for ECS' started by APTanner, Apr 3, 2024.

  1. APTanner

    APTanner

    Joined:
    Apr 21, 2018
    Posts:
    1
    TLDR: What parts of ECS would need to be changed to make it fully cross-platform deterministic?

    I know that unity physics and burst are not fully deterministic (deterministic on all hardware) due to differing implementations of floating point operations. However, if you used some deterministic number type rather than floats (and avoided system.math), are there any other considerations to getting full determinism?

    For example, is there any way of ensuring structural changes (entity layouts in chunks) are deterministic? A fully deterministic physics system would probably still depend on the order of the physics bodies so this could break determinism.

    I'd like to create a replay system by storing only inputs and having these replays play out identically across any desktop hardware. What do I need to take into account/what built-in systems will need to be changed for this to be possible? I am just doing this for a hobby project; I don't mind if it takes more effort than it's worth, but I'd like to know what it would involve.
     
    eventropy likes this.
  2. eventropy

    eventropy

    Joined:
    Oct 4, 2012
    Posts:
    256
    I'd be interested in this as well. If it was easy enough to do, we could patch the physics package ourselves and use this custom version.

    What would be the correct approach in theory? Multiply floats by 100000etc, convert to int, run physics simulation, convert back to float (and divide by 100000etc), then do the export of physics state for rendering etc? If one of the unity devs could chime in then maybe we could try stuff like that instead of waiting for them to fully support determinism