Unity Dr. Mario logic

Hi,

im trying to make a 2D game like Dr. Mario in Unity. But i don’t know how i can make blocks falling after destroying the siblings that collide with another block.

any ideas?

Use 2d physics so they fall naturally?

I would probably avoid using physics for this because doing so may lead to irregularities in the movement of your pieces due to things like friction or snagging.

In my game, I have “crush blocks” that fall if the ground beneath them is destroyed (moved-- it could be another crush block, after all). This was a huge pain in the butt, and in fact, I ended up using physics for mine (but you probably shouldn’t. That part of my solution is ugly). Anyways, the way I did it was by including a script on each crush block that had a reference to a game object which is set in the OnCollisionEnter2D function to whatever object the crush block hit (provided the object is below, and not beside this block). The script also has a Vector3 which stores the position of the object at the time of collision. And then in the Update function, it’s constantly checking to see if that game object is null (was destroyed) or if its position is different from the position it was originally at. If either have changed, then allow the block to fall again.

There are other was of doing this and I guarantee there are better ways (possibly using callback functions when a block is destroyed or something instead of checking if an object != null in Update), but that’s how I figured it out.

can you show me a code example or did you know a good tutorial?

Same question, did you have example project?