Two Rigid Bodies Adding Unwanted Force

Hi all,

TLDR: Character with rigidbody standing on box with rigidbody adds unwanted sideways sliding force. How do I fix this?

So I’m creating a game with movable object I want to be able to push around and use to step onto to for puzzles and getting onto tall objects. I have created my box that i want to use and it works perfectly until I try and stand on it. on perfectly level surface its barely noticeable but even 2-3 degrees its like ice I slide right off.

With I tested to figure out that the two rigidbodies were the issue. I’m currently using a character controller form the asset store. EFPC.

Does anyone have any solutions or suggestions on how to fix this?

I’ll guess that you’re not calling the physics API but instead directly setting position or rotation.

With Physics (or Physics2D), never manipulate the Transform directly. If you manipulate the Transform directly, you are bypassing the physics system and you can reasonably expect glitching and missed collisions and other physics mayhem.

Always use the .MovePosition() and .MoveRotation() methods on the Rigidbody (or Rigidbody2D) instance in order to move or rotate things. Doing this keeps the physics system informed about what is going on.

The movement of the box is completely collision based there are no specific ways the box needs to be moved just running into the box to get it to where it needs to be. I want these boxes to tumble and roll down hills off the sides of structures etc. So would your advice still apply with my situation?

But what about the character?

Also, usually when you stand on a rigidbody the best way to stay still is to hook up with a FixedJoint, which you break when you want to leave. That’s how must physics-based platformers work.

When you see the physics system not being quiescent and coming to rest there can be a lot of different things contributing to it, such as mis-using the API and effectively adding energy into the system each frame, or by masses being too different (eg, a large mass atop a much smaller mass).

Things to mitigate:

  • use the physics engine correctly (as above)

  • always use continuous dynamic collision checking (on the rigidbodies) to reduce penetration

  • use as few constraints as possible (constraints can add energy)

  • use more drag and more angular drag

  • use less-slippery materials

  • and probably 50 other tribal knowledge techniques. :slight_smile:

For instance, see the enclosed ultra-simple scene:

1kg block on floor
10kg capsule above it

Toggle the X/Z rotation constraints on the Capsule… without constraints it bounces and falls over, but with constraints it marches slowly off the side of the cube, sorta like what you see with yours.

Physics is tricky… the more stuff is actively touching, the harder a problem it is for the engine to solve.

8431346–1116434–PhysicsQuiescence.unitypackage (4.52 KB)