[SOLVED]Player Jumps on Enemy?

Ok, so i know how to respawn my player if in collision with enemy. But how do i make the player having a sense of attack, like in a Mario game you can demolish an enemy by jumping on it. Please help. :pleading_face:

Hi!

There are different ways of doing it, here is one. Let’s assume that we have the SlimeMonster. If Player collides it by walking, the Player spawns to the checkpoint. However, if Player jumps to it, the SlimeMonster disappears.

Here is the code, how to do it:

There are two sub events under the collision between the player and SlimeMonster. There are many different conditions for platformer character, such as “Player is moving / jumping / falling” etc. The subevents then checks whether the Player is falling (the end of jump) or not falling (notice that the second subevent has the inverted condition for falling).

Hope this helps. :slight_smile:

Hi, thanks for helping me ALOT. But it does not work still despite what i did (exactly what you said)
What happens instead is that the player cant move or jump. Please check my code im pretty sure there is something wrong about this. :sob: :sob: :sob:

No you didn’t. @PalelevaPingviini has a collision event with subevents that check whether the player is falling or not. You don’t have this event structure. You have the events, but they’re all the same level and scattered around.

1 Like

ohhh… let me try that again…

like this?

Sure i can move now but i still cant kill the enemy by jumping on it.

Almost. GDevelop processes event sheets from top to bottom. This means the first event of the screen snip will get processed before the last event.

The first event checks for collision between hero and slime_pike (by walking or falling into it), gets the last Checkpoint and then moves the player to the checkpoint and reduces the value of FlatHeartBar.

By the time the last event is processed, the slime_spike has been deleted, the player has been moved and the event never gets actioned.

To fix this remove that event at the top of the screen snip, and add a decrease FlatHeartBar value action in the last event of the screen snip.

1 Like

well actually there is even more on the screen…

But il do what u said

Yo! It works! Thank You Sooooo Much bro! :star_struck: