Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

physics mass units (and changing dynamically)

Discussion in 'Physics' started by JoeStrout, Jan 8, 2015.

  1. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    8,316
    I know that Unity's physics engine, by default, is scaled for 1 unit = 1 meter. The documentation on Rigidbody.mass doesn't specify units, but I would assume this is kg. But the docs do say: "You should strive to keep mass close to 0.1 and never more than 10. Large masses make physics simulation unstable."

    This really makes me wonder. The standard unit cube, if made of something with the density of water, would 1000 kg. You basically can't make any realistic human-scale object under 10 kg. Could it be the mass units actually be tons (1000 kg)?

    Second question: how unstable are we talking about, with big numbers? We want to simulate something like a Falcon 9, which weighs about half a million kg (or about 500 tons), and lifts off with about 5000 kN of force. If we plug those numbers into the Unity physics engine, is it going to blow up? Or is it only a problem when colliding with other objects (which we don't plan to do)?

    Final question: is it OK to change the mass of an object (for example, because you're burning fuel and throwing it out the back) during the simulation? I would assume so, since nothing says not to, but it'd be great to know whether this "just works" or whether we have to somehow tell the physics engine to recalculate something.

    Thanks,
    - Joe
     
    Nanako likes this.
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,168
    The units are arbitrary. You should try to keep the mass around 1 as the docs say; the physics engine does not do well with extreme scales due to floating point limitations. So for your jet, define 1 unit of mass as 0.5M kg and use that for all the math. Changing mass at any time is fine.

    --Eric
     
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    8,316
    Hmm... maybe the claim that the physics engine assumes meters comes from the default gravitational acceleration (9.8 units/sec), but all other units are arbitrary.

    Still a bit of a pain, since if I scale mass, I have to also scale force... but, such is life I guess. Sounds like it will do at least for a while.

    Thanks!
    - Joe
     
  4. Partel-Lang

    Partel-Lang

    Joined:
    Jan 2, 2013
    Posts:
    1,963
    If you will not build any complex constrained systems, it doesn't really matter if you use extreme weights. I don't think its a floating point issue, the mass property only has a meaning relative to another non-kinematic body if it becomes constrained or into collision with it.
    So it doesn't kill the engine, you just don't want to constrain multiple extremely heavy objects to very light ones or have complex collisions between them.

    If you just need to apply Newtons to your Falcon, it should be OK to use whatever mass you need. If you plan to take that Falcon to orbit in m/kg units, then you'll have floating point problems though for sure. :)
     
  5. DryTear

    DryTear

    Joined:
    Nov 30, 2012
    Posts:
    312
    you could have the mass whatever you want, and then in your code, at the awake function, you can scale everything by a multiplier.
     
  6. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    how does 10 kilos come anywhere close to floating point limitations?
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,168
    Not by itself, but when combined with other factors when doing calculations. Although from what I've seen 10 seems low; I've done 100 without apparent issues.

    --Eric