[GD4] Player "dead" animation Mario style?

What I want to do is to add a Mario style death animation :smiley:

  1. Toss the player up and back a bit
  2. Let the player fall through the ground

What should I do?


When the player is hit:

  • Change the player’s animation to the death animation
  • Make the player jump
  • Disable the Platform’s (not the player’s) Behavior

This should make the player jump then go through the platform while falling when he/she dies.

But if I disable the platform, won’t the enemies fall through as well?

Yep that is what happen. Maybe you use physics behavior and when you collide with enemy:
Deactivate platform behavior of the player and activate physics behavior and add small impulse to the angle of 270.

Thanks. I think I understand now. :smiley:

In fact, you don’t need the physics behavior to animate the player when he dies. Just use the built-in forces to do the animation. But before doing so, deactivate the platformer behavior on the player’s sprite (you don’t need to deactivate the platform behavior of the platform object).

Lol, yes. Every object that has the Platformer Sprite behavior will fall through.

Yeah, I figured out it was the platformObject property that prevented force from taking effect. I also tried the physics solution, because I might want to use bullet in the future as well.

Now I decide to let the player stay on the ground and go to the game over screen when the death animation is finished.
Thanks for your help everyone.

Wouldn’t it be easier to create a new object? So this new “KOed” Mario object spawns whenever Mario “dies” in the game (remove the real Mario or turn him invisible + disable controls) . Like an explosion appears when you defeat an enemy plane in a shoot’em up game.

This new object doesn’t have use platformer physics and moves upwards, then a timer activates a downwards movement. Sorry, not on my regular PC now, will try to post a screenshot of the code I have in mind later.

EDIT: This is very basic and of course needs more adjustments. Just to give a general idea of what I had in mind
So if you run into an enemy, the player turns invisible and a “KOed” player sprite is created where the player was. This KOed sprite moves up, then slowly drops out of the scene. Important: The force that moves the KOed player up at 270° needs to have damping set to “0”, the force that pulls him down at 90° needs damping set to “1”.
This needs a bit more code here and there, like a code that restarts the scene and a code that prevents the invisible player from moving around.

So, why do you use another object instead of the player itself?
Maybe to stop the camera from following it?

That is a useful side effect I haven’t been thinking about to be honest. I was thinking about the platform/physics engine problem. This new object doesn’t follow the rules set by the platform engine and simply drops out of the screen, it will not interact with the floor, ceiling, walls etc. So it can be used while leaving the platform engine untouched.

Well today I just found I couldn’t make the player leave the ladder without an input.

Simulate Pressing Ladder key for PlayerObject
Simulate Pressing Jump key for PlayerObject
Simulate Pressing Release key for PlayerObject

None of those above works.
I just want the player to drop from the ladder when a bullet hit(kill or not) him.

The only way that worked was changing the Platform property for the ladder.


As a normal policy, please do not bump multi-year old threads. This would have been for GD4 since GD5 was only released in 2018. Most of the logic is the same, but you’d need to translate some of it to the newer event structure

You are welcome to make a new thread inquiring on how to do this, but I think I actually do something similar to what is being discussed here (Disabling the player controls, moving the player sprite as part of it, etc) in the knockback/player damaged logic in Not-a-vania, so you can look at that in the main example list if you would like. I think I also do something similar for the death animation, but I fade the character to grey instead of play another animation, the core logic should be the same.