Bouncing Item with Platformer Behavior

Hello. I have implemented a healing Heart item in my game with the Platformer Character behavior (With default controls unchecked) to give it gravity. When it falls to the ground, I want it to bounce up and down to add a nice little quality of life effect. However, I’m kinda struggling on how to accomplish this otherwise simple task. First of all, when the heart(s) land, the event that checks if they’re on the floor adds a force to bounce them upwards. However, when the heart lands, it doesn’t bounce. A second later though, it starts doing small bounces, and eventually doing bigger bounces over time until it’s bouncing ridiculously high. It’s even worse with multiple hearts on screen, which causes one, or all of the hearts to bounce, and then levitate upwards, getting stuck on the ceiling.

I’ve tried everything I could, including the “For Each Object” event, the “Trigger Once” condition, and using variables.

I am out of solutions. Please share with me your knowledge on how to make Platformer Character objects bounce every time they hit the floor. I would greatly appreciate it. Thanks in advance. :slight_smile:

P.S. I would prefer to not use the Physics 2.0 behavior, because it might break some other mechanics in my game. If this can be done with the Platformer Character behavior, then please tell me.

1 Like

Can it be as simple as when the heart is in collision with the floor, the action is “simulate Jump” instead of adding a force?

Hi!
It can be done with platformer behaviour, but it will be more work than using Physics, and the end result probably won’t look as good. Using Physics shouldn’t break other mechanics.

With platformer behaviour, you could use a jump counter (object variable), and after each bounce/jump, you reduce the jump height and you increase the jump counter. When the counter reaches 3-5, you make it stop.
If your hearts jump higher and higher, there’s something wrong with your events.

Thank you. You suggestion works great!
However, when I have multiple hearts on screen, they don’t bounce like as much as they should when there is a single heart on screen. I tried using “For Each Object,” but nothing changed. Can you please help?

P.S. If it helps, I’m using beanmatt’s suggestion with “Simulate Jump” instead of using forces.

You’ll need the for each, and you will need to store the jump’s height value in an object variable , like the jump counter, so that each heart has its own.

I already had “For Each” and Object Variables when I asked this.
Here, I’ll upload a screenshot if it helps:

EDIT: I removed “Trigger Once” from the code, and it seems to be working like I want it to now.

1 Like