I want to know how much weight is supporting a collider/rigidbody.
It can be done somehow, because the wheel colliders know how much weight they are supporting and if you add a cube with a rigidbody above the vehicle, they update its supported weight.
So I need to know the weight supported by a collider/rigidbody. Any idea?
No thread shall remain unanswered Maybe you no longer need it but I just had the same question and after a bit of trial and error I came up with a pretty good solution.
What you have to do is to assign this script to a Rigidbody with a box collider.
For simplicity, I only used the Y-Axis for measurements.
Basically, we have to add up all the impulse values of collisions with our weight scale. In fact, it could be optimized even more, by transforming the impulse vector to the weight scale object and only using the force that pushes downwards on it. But for regular use, this will work just fine.
@McDev02 This is amazing! Thank you for sharing this! I’ve been having some difficulty with some calculations of odd-sized objects with odd center of mass. I was able to use your code above to allow me to set percentages of weight at certain points.
I am now trying to figure out how I can do this at run time with moving objects! This is a great start, thank you!
Hi, can you tell me few evidence to understand what it is wrong when using the script.
If i set only kinématic no change. i have to use gravity…
Your box collider has 0.2 on Yaxis , why ? not to fill the 3d object ?
Thanks for the help
I am dumb, will this calculate the weight of cubes that are not colliding with WeightScale, but are lying on top of another cube, which are colliding with WeightScale?
Yes, because of how physics solvers work: they iteratively apply impulses between pairs of objects. The magnitude of these impulses is adjusted in multiple iterations over all pairs of objects, so the final impulse applied at the end of the frame between the scale’s floor and the cubes immediately on top of it already considers the mass of cubes higher up.
If this wasn’t the case, stacks would simply not work: the impulses applied by the floor would only consider the mass of the boxes directly on top of it and not the mass of all stacked objects, so they would just fall trough the floor.