Odd Physics Behaviour

I have a very simple setup, and observe some imprecise behaviour with the physics in unity.

I create two simple identical dynamic boxes, and I place one on the floor, and the other on segment of the floor with a small crack in it. Then I attach a simple ‘add a force’ script to both boxes, and edit it to add force in the upwards direction.

When I add force to the boxes, the box not on the crack jumps about twice as high into the air as the box on the crack. It does not matter have wide the crack is - as long as a box is in contact with two surfaces instead of one, it will not fly as high when added a force.

This behaviour seems very imprecise and impractical. Anyone know if I might be able to configure something that might change this?

What happens if you turn off friction?

Also the box on the right appears to be slightly into the geometry? Have you setup rigidbodies with gravity and let them drop to there floor rest point?

Friction has no effect, and yes, the boxes are resting with gravity on the floor.

I found out that by using ForceMode.Impulse as parameter to the AddForce function, the jump height of the boxes became stable.

Can anyone explain this?

An impulse is a “one time force” which only has its consequence post the application. Its fully simulated FPS independent in the background.
Or physically speaking, its the consequence of an impact of an object with mass on another object with mass, its the energy share that this object got from the other upon that impact.

A force normally is expected to be a “constant influence” (friction, gravity, motor drag, pushing, …). Forces are no energy, the are local, momentary effects so if you take them away their impact is gone too as there is no energy to continue the previous movement.

But suppose you want to build an electromagnet to affect the boxes for a half second. Then I think a pure AddForce would be a reasonable solution - however the two boxes still get a different velocity. To me it looks like an odd behavior.

I tried running the test without unity in a pure PhysX/C++ environment and the same odd behavior occurs. However by adding:
gPhysicsSDK->setParameter(NX_ADAPTIVE_FORCE, 0);
it fixes the problem and the two boxes moves identically. Perhaps this setting should be available in unity?

Of course there is disadvantages by disabling the adaptive forces according to the PhysX docs:
—Adaptive force—
By default, PhysX uses an adaptive force scheme, in which the acceleration of bodies that are touching large numbers of other bodies is scaled down (on condition that some of the bodies are in contact with a static object). This causes a dramatic improvement in solver stability in many cases.
Adaptive force may in some instances lead to unwanted physical artifacts in the way objects move. Because of this, there is the option of disabling adaptive force throughout the SDK:
gPhysicsSDK->setParameter(NX_ADAPTIVE_FORCE, 0);
However, because of the abovementioned stability implications, this should not be done lightly.

1 Like

Where do you you add this line: gPhysicsSDK->setParameter(NX_ADAPTIVE_FORCE, 0);?