DEV Community

Katana Works
Katana Works

Posted on Originally published at learn.katanaworks.dev AI-assisted

GDevelop Death Animation in Minutes:

You don't need keyframes or a state machine for a good death animation. I swap the player for a particle effect, wait a beat, then respawn. Three events, about five minutes of work.

What you need first
A player that moves and collides
Something that kills you (spike ball, enemy, hazard)
A respawn or checkpoint system (this one only handles the animation, not where you come back)

Step 1: Group your hazards
Put every deadly object into one group called Enemies. Spikes, enemies, lava, whatever. One event covers all of them, and new hazards later cost you nothing.

Step 2: The death event
Conditions:

Player is in collision with Enemies
Trigger once while true

Trigger once matters. Without it the collision fires every frame and you stack a pile of effects that tanks performance.

Step 3: Spawn the effect, then delete the player
Actions, in this order:

Create object DeathEffect at X: Player.CenterX(), Y: Player.CenterY()
Delete Player

Create first, delete second, so the position is still readable. Deleting the player also kills movement and stray collisions during the animation.

Step 4: Wait, clean up, respawn
Add these actions after the delete:

  1. Wait 0.5 to 1 second (needs the Advanced Wait extension, install it from the extensions list if you don't have it)
  2. Delete DeathEffect
  3. Run your respawn logic

Too short and the player never sees the effect. Too long and people get annoyed waiting. Half a second to a second works for sparks and flames.

Swapping the look
The logic doesn't care what the effect is. Change the object in the Create action and you're done. Electric spark for sci-fi, blue flame or smoke for fantasy, pixel explosion for retro. Keep it centered on the player and nothing else needs touching.

Recap

Group hazards so one event covers everything
Trigger once while true on the death event
Create the effect at CenterX() / CenterY(), then delete the player
Wait, delete the effect, respawn

Questions or a different setup? Drop a comment. Next up I'm tying this into the checkpoint system.

Top comments (0)