Search Unity

Inconsistent ragdolls

Discussion in 'Physics for ECS' started by jtoikka, Nov 25, 2019.

  1. jtoikka

    jtoikka

    Joined:
    Aug 23, 2017
    Posts:
    2
    Hi, I'm using Unity Physics for a research project. My set up is as follows: I create multiple agents/ragdolls all starting from the same state (with collisions between them disabled), then simulate forward for a few steps. If I don't change anything, I would expect them all to end up in the same future state.

    This is what the simulation looks like with one agent:


    And here it is with two agents:


    Although the two agents are identical, they end up diverging. I'm guessing this has something to do with how constraints are sorted and solved.

    Any suggestions for how I might enforce a consistent solution for each ragdoll, such that identical ragdolls starting from the same state will simulate in the same manner? For performance reasons, I would prefer to keep the ragdolls in a single physics world.
     
  2. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    Both simulations are not the same (different number of bodies and joints) and so determinism should not be expected.
    You could try setting up one PhysicsWorld and then cloning it, making one clone for each agent, and stepping each clone independently. The performance shouldn't be that different from one world will all ragdolls and collision disabled.
    The Immediate Mode pool demo is doing this for drawing future ball trails (Note, that we have a jobified more performant version of that demo coming).

    The downside of cloning and manually stepping the worlds is that you will need to handle the update of the graphical elements yourself. The upside is that they are properly deterministic and independent runs.
     
  3. jtoikka

    jtoikka

    Joined:
    Aug 23, 2017
    Posts:
    2
    Thanks, I'll give it a shot! Looking forward to the updated pool demo.