matter-js
matter-js copied to clipboard
Dropping Bodies into another body
This is more of a help question, so please feel free to direct me elsewhere if appropriate.
I am trying to work out the best way to essentially drop a bunch of small bodies into another body and 'capture' them. The larger Bodies would be relatively complex SVGs, but none with holes.
I have a (bad) attempt here: https://codepen.io/rking123/pen/BaGRmXd
I was thinking:
- turn collisions off;
- applyForce the smaller shapes towards the SVG (an arrow in this case)
- Detect collisions, and turn then back on once smaller shapes are in the bounds of the SVG.
But, it's proving pretty tricky. Has anyone tried anything like this before, or able to point me towards an example? https://brm.io/matter-js/demo/#terrain example is probably closest, but that would involve having a hole at the top of any SVG for small shapes to drop through.
Thanks