Consider the following scenario with multiple RigidBodies interacting with each other:
What I want is a measure of the tension or stress on RigidBody4.
It doesn’t have to be the precise value, just any quantity that can vaguely relate to it is still ok.
One logic way to calculate it is to get the normal force on RigidBody4 applied by the ground; or the force applied on RigidBody4 by RigidBody3. But I couldn’t figure out how to get those values from the physics engine.
Any ideas?
IMPORTANT: I’m definitely NOT interested in any hack-ish way of manually calculating it. Anyone can easily figure out that kind of solution. What I want is a simple and elegant solution that uses data from the physics engine.
edit Example of solution I’m not interested in: “make a tree with all the rigidBodies that are in contact with each other, then calculate the contact forces”.
The physics engine doesn’t provide that data. Furthermore when the rigidbodies velocity drops below the resting limit, it falls asleep and doesn’t do any physics calculations anymore.
You have to do it “your hacky way” which is not really hacky.
The physics system is ment to simulate physics, not to calculate them correctly. The system is based on velocity, not on forces. You can use forces to accelerate an object, but the force is just divided by the objects mass. Gravity is also applied as acceleration, no as force. Drag doesn’t exist at all. Just a drag coefficient which is based on the velocity.
Maybe PhysX has some more information internally, but Unity just provides what the Rigidbody offers.
I had an idea:
Apply a force F to the RigidBody and watch out for an increment in position or velocity. If there is no increment, increment F. When the increment happens, then F is approximately the value of the tension in the RigidBody.
This is only works for the static case and it is pretty hacky and un-elegant, but at least it doesn’t require to manually compute all the dynamics of the RigidBodies, which should be already somehow calculated by the physics engine. I think something on this direction could work.