How to setup physics to accurately represent stacking blocks?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By i_love_godot

Hey all :slight_smile:

First off, I just want to say that I love Godot and I’m having a lot of fun playing around with it. That said, I am quite new to it so I apologise if I’m missing something really obvious.

For reference, I am using Godot 3.1 Alpha 5.

I’m trying to recreate a classic “stacking” game, but the physics just doesn’t seem quite right. I am using RigidBody2D for the blocks and a StaticBody2D for the ground. However, the blocks seem to “slip” or “compress” sometimes that causes the stack to topple over or the middle blocks to move out of the side.

I have tried increasing the mass, which helps a little. I have tried adding a PhysicsMaterial with high friction which helps a little. But something is still not right. Even with a near perfectly aligned stack of blocks, all of sudden the entire tower compresses vertically then collapses, pushing blocks out of the side. It’s quite strange.

To give an idea of what I am trying to emulate, imagine concrete blocks. They won’t compress or slip out the sides, but they would topple if the weight at the top is uneven.

Also, when a block first hits the ground it appears to go into the ground body, before being pushed back out to the boundary. Is there a setting to prevent bodies from entering each other? Maybe increase the physics computation?

Apologies if this is not a clear question, and let me know if any more info would be helpful. Thanks for any hints/tips/advice you can offer!

:bust_in_silhouette: Reply From: Calinou

This is a known bug: Pile of RigidBody2Ds results in overlapping and shaking · Issue #2092 · godotengine/godot · GitHub
Increasing Physics Fps in the Project Settings may make the jittering less noticeable at the cost of higher CPU usage.

Handling stacked RigidBodies has always been a difficult problem to solve in a physics engine.