Search Unity

Calculate mass held by rigidbody 2D

Discussion in 'Scripting' started by FabrizioSpadaro, Feb 19, 2020.

  1. FabrizioSpadaro

    FabrizioSpadaro

    Joined:
    Jul 10, 2012
    Posts:
    287
    Hello, I have a "simple" question, is there any way to calculate how much weight a rigid body is holding?
     
  2. TheDevloper

    TheDevloper

    Joined:
    Apr 30, 2019
    Posts:
    69
    Well, their is an option attached to the rigid body is called mass go check it out.
     
  3. FabrizioSpadaro

    FabrizioSpadaro

    Joined:
    Jul 10, 2012
    Posts:
    287
    Yeah, well I know that every object has a mass, but how can you calculate how much muss is HELD by 1 rigid body.

    Imagine you have a plane, and on top of this plane you have 30 more rigid bodies, how can you calculate how much mass that plane is holding?
     
  4. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,639
    Calculating the mass would be simple- just add 'em all up. It sounds like the real problem is how to figure out which objects are "held". Maybe you could use colliders for that.
     
  5. FabrizioSpadaro

    FabrizioSpadaro

    Joined:
    Jul 10, 2012
    Posts:
    287
    Well not even that, because some objects could distribute some of their mass outside my target.
     
  6. FabrizioSpadaro

    FabrizioSpadaro

    Joined:
    Jul 10, 2012
    Posts:
    287
    I think I found my solution, and I will be using reactionForce.magnitude of a spring joint
     
    TheDevloper likes this.