So, I built a simple physics engine (without rotation as of now)

You can click and then release to create block with velocity.


enter image description here

Now, I want to apply force at the bottom most block. Currently, the block will only slide without affecting the other top blocks.

Now, I can only think of a simple algorithm to make all the top blocks slide when the bottom one slides which goes like this,

  1. shift the current block
  2. find the blocks on top that touch the current block,
  3. recurse each such block and goto step 1

But there are problems with this algorithm(double additions for example, but easy to fix with a boolean flag).

So guys, how do I make all top blocks slide when the bottom one moves?


Moving a cube under another one is the same as moving the one on top in the other direction. Friction keeps them together. So, when you detect a collision from the top, get the force applied to the bottom cube and apply it to the one on top as well.

  • \$\begingroup\$ Can you add some references so that I can study more in depth? By the way is it an easy problem? \$\endgroup\$ – uttamkhanal Mar 23 '18 at 13:16
  • 1
    \$\begingroup\$ Look for "static friction," specifically. \$\endgroup\$ – jzx Mar 23 '18 at 19:05

The force on top cube should be equal to the force applied on the bottom one, minus a slight amount, which is the dynamic friction coefficent

  • \$\begingroup\$ how do i handle complex block structure where more than two blocks are on top of the bottommost block? \$\endgroup\$ – uttamkhanal Mar 24 '18 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.