2
\$\begingroup\$

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

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

https://codepen.io/kingofdelphi/pen/vRZvxQ

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?

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

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.

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

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .