Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Kimbatt/unity-deterministic-physics
Cross-platform deterministic physics simulation in Unity, using DOTS physics and soft floats
https://github.com/Kimbatt/unity-deterministic-physics
deterministic physics physics-engine physics-simulation unity unity3d
Last synced: 3 months ago
JSON representation
Cross-platform deterministic physics simulation in Unity, using DOTS physics and soft floats
- Host: GitHub
- URL: https://github.com/Kimbatt/unity-deterministic-physics
- Owner: Kimbatt
- Created: 2021-02-16T17:56:07.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-02-14T00:32:54.000Z (12 months ago)
- Last Synced: 2024-08-02T05:13:12.619Z (6 months ago)
- Topics: deterministic, physics, physics-engine, physics-simulation, unity, unity3d
- Language: C#
- Homepage:
- Size: 12.5 MB
- Stars: 470
- Watchers: 12
- Forks: 60
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-unity3d - unity-deterministic-physics - Cross-platform deterministic physics simulation in Unity, using DOTS physics and soft floats (Open Source Repositories / DOTS)
README
# Unity deterministic physics
This is a modified version of [Unity DOTS Physics version 0.6.0-preview.3](https://docs.unity3d.com/Packages/[email protected]/manual/index.html), which supports cross-platform deterministic physics simulation by using [soft floats](https://github.com/Kimbatt/soft-float-starter-pack).
## Usage
The following packages must be installed:
- Burst
- Collections
- Entities
- JobsYou'll need to use the `UnityS.Physics` and the `UnityS.Mathematics` namespaces instead of the usual `Unity.Physics` and `Unity.Mathematics`.
See [Unity Physics manual](https://docs.unity3d.com/Packages/[email protected]/manual/index.html) for documentation.
## Notes on determinism
For a deterministic physics simulation:
- All bodies must be created in the same order every time you create the simulation
- Bodies must only be modified in a system that is updated in FixedStepSimulationSystemGroup
- You must not use the result of floating point operations as input for the physics engine
- Be careful when using hashmaps / hashsets, because iterating over them may be non-deterministic (it depends on the implementation).
- Check how to use soft floats [here](https://github.com/Kimbatt/soft-float-starter-pack#how-to-use).
- Make sure that your code is also deterministic.## Example
See the ExampleScene scene for an example. After running it, your simulation should look exactly like this:
![](deterministic.gif)## License
`Unity.Physics`, `Unity.Mathematics`, and `Unity.Transforms` are licensed under the [Unity Companion License](https://unity3d.com/legal/licenses/Unity_Companion_License).`Soft floats` is licensed under the MIT License. See [https://github.com/Kimbatt/soft-float-starter-pack](https://github.com/Kimbatt/soft-float-starter-pack) for more information.