Giter VIP home page Giter VIP logo

unity-deterministic-physics's Introduction

Unity deterministic physics

This is a modified version of Unity DOTS Physics version 0.6.0-preview.3, which supports cross-platform deterministic physics simulation by using soft floats.

Usage

The following packages must be installed:

  • Burst
  • Collections
  • Entities
  • Jobs

You'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 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.
  • 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:

License

Unity.Physics, Unity.Mathematics, and Unity.Transforms are licensed under the Unity Companion License.

Soft floats is licensed under the MIT License. See https://github.com/Kimbatt/soft-float-starter-pack for more information.

unity-deterministic-physics's People

Contributors

kimbatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity-deterministic-physics's Issues

How is this different from the Unity DOTS Physics?

Hi there,

You reference the Units DOTS Physics package in your readme, which claims to be deterministic in its description.

Is the difference here that the Unity DOTS Physics package is only deterministic on the same platform/processor, while this project is deterministic across platforms/processors?

Looks like a cool project!

rollback?

Is it possible to roll back the physics engine to an earlier state with collisions?

2D support

Hi,

Can you add support for 2D physics + a 2D example? Thanks!

Hi, Is it possible to release the auto generation unity code tool?

Hi, Is it possible to release the auto generation unity code tool?
xxx.gen
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------

Editor Authoring functionality missing

First of all I'd like to thank you @Kimbatt for sharing this project. So far it has worked great.

Unity DOTS physics has editor authoring components with the included Unity.Physics.Editor & Unity.Physics.Hybrid (not entirely sure if both are required). With Unity.Physics it is possible to design gameobjects in the editor and use those in the code through subscenes and entity prefabs, but the authoring components are not compatible with this project. At the moment including Unity.Physics.Editor & Unity.Physics.Hybrid gives a ton of errors. I think this project would be complete with the authoring functionality.

Physics quite unstable

I tried playing around for few days with these packages, sadly I can confirm it is far from production ready.

Cylinder/Mesh colliders are very unstable. Also tried the same setup with float version and issues was gone.
unstable-physics

Frictions are quite off, as objects loses the force almost 2x faster than in float version.

sfloat:
friction-deterministic

float:
friction-no-deterministic

P.S. Yes the scenarios here shown are not exact the same for comparison. But it is quite obvious then u play around in the scene and in float version everything slides completely differently.

In any case, it is cool package modification and nice attempt for deterministic physics. However, if you dont plan using only boxes and sphere likes in example, you wont find this package doing what you want.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.