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. Dismiss Notice

Relations of DOTS Physics variables?

Discussion in 'Physics for ECS' started by tonsillectomy, Jun 14, 2020.

  1. tonsillectomy

    tonsillectomy

    Joined:
    Jun 2, 2015
    Posts:
    18
    Hi,

    I was trying to find some clarification for the variables used in DOTS Physics, but couldn't find any. Lets say I was trying to add a density variable into the physics system. How should I go about doing this?

    I was trying to find the mass of an object, but could only find inverseMass, inverseInertia and volume.
    How exactly are these related to the overall mass of the collider, and what is the "inverse" in these variables relative to?

    First I thought that the "Mass" in the PhysicsBody component was actually the density of the collider, but I had to ditch that theory after debugging and getting these values:

    Sphere collider of scale 1,1,1 and mass 1:
    Volume: 0,5235988f
    InverseMass: 1f
    InverseInertia: 10f,10f,10f

    Box collider of scale 1,1,1 and mass 1:
    Volume: 1f
    InverseMass: 1f
    InverseInertia: 6f,6f,6f

    So what exactly is the "Mass" variable in the PhysicsBody component and what are the relations of these variables mentioned above?

    Thanks!
     
  2. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    Volume is the actual volume of the colliders, so you could multiply your density with the volume to get the mass for example.

    Mass is literally mass from physics class, so it's how hard it is to change a bodies velocity basically. So you can put in somethings mass in kilograms, grams, or other mass metric. It doesn't actually matter what metric you use since the only important bit is the relative mass between bodies. eg: a 1kg cube hitting a 10kg cube will have the same physical behavior as a 10kg cube hitting a 100kg cube. it's all about the relative mass. So the small cube has 1/10th the mass of the body it's hitting.

    Inverse mass is the reciprocal, so 1f/Mass. This is what a lot of the equations use so it saves some math operations to have it be inverse.

    Inertia is how hard it is to change a bodies angular velocity. It's basically rotational mass. You can imagine something like a rod rolls around it's axis very easily but spinning it around any other way takes a lot more energy. Again, it's inverse for math reasons. There's a bit more to "inertia tensors" like this sadly, since they can have a relative rotation and such.
     
  3. MaxAbernethy

    MaxAbernethy

    Joined:
    Mar 16, 2019
    Posts:
    53
    For bodies of uniform density, inertia is proportionate to mass. In your examples you have inertias calculated for mass = 1. If you wanted to calculate what the inertia would be if the body were 10 times denser, so that it had a mass of 10, you would just multiply the components by 10, or in this case divide the inverses by 10.
     
    tonsillectomy likes this.
  4. tonsillectomy

    tonsillectomy

    Joined:
    Jun 2, 2015
    Posts:
    18
    Thanks guys! :)