[SOLVED] How to make Block Bounce When Hitting It (Super Mario Bros.)

Hi, can someone help with this? I’m trying to give a “bounce” animation to item blocks using forces and it seems like it should work consistently using this code:

As you can see, my parameters are that when Mario comes into contact with both the Question Block and the HitboxCheck object, it adds a force directly upward, waits, then adds an equal and opposite force downward. It stands to reason that this would result in the block bouncing up, then down and landing in its original spot, right?

Well, that doesn’t seem to be the case. Sometimes I get the block landing exactly where I want it, but most times, it ends up either one pixel too high or too low.

I’ve tried rearranging the order of events, adding “Stop Object” events between the forces, and tweaking the values, but nothing is giving me any consistent results. Any and all help with this would be greatly appreciated!

EDIT: Additionally, I’ve noticed another problem. As I use the “Repeat for each instance” function for other types of item boxes and bricks, my game starts to lag HARD. I’ve now removed the offending function, but I still need to be able to have the parameters be true for all instances of that same type of object without it being so taxing on the system. The parameters should be able to be reused and tweaked for other similar objects, such as the blocks with items inside, bricks that give a star, and the 10-coin bricks.

Use the tween behavior and tween object scale + y position also check this tutorial at the moment 3:55 https://youtu.be/vdYi8Miwv2E?si=uBbnSQujO5zkonC1

1 Like

Well, that solves my performance problem, but the block still doesn’t land consistently in its original spot, for some reason…

Be sure the tweens are being executed symmetrically and I would recommend you to use “linear” easing.


Change Y
Change size
Change size (reverse)
Change Y (reverse)

Right, but I don’t want to change the size of the block (I’m aware it does that in later Mario games, but not the original Super Mario Bros.)

My values seem to be consistent enough for the regular item boxes:

But the same cannot be said for the brick object, which is supposed to bounce indefinitely if you’re small Mario. The values seem symmetrical, and the only difference is that the brick doesn’t change to a different animation and keeps playing the tween:

Use “Trigger once” at the brick event.

Better option:

Use a condition to check if the tween is not already playing (make it be the last condition)

Add trigger once to the event with the collision condition.

Don’t use the wait command with tweens.

Start a tween, then use another event to check if that tween has finished. Once it has, remove it and then start the next tween:

1 Like

That did it! Thank you so much! You too @Reborn ! Now to adapt it to all my block types!