Skip to main content
2 of 2
edited body
user avatar
user avatar

Relative motion physics

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?

user114849