"Enemy" die effects (Platform Game) - Help

Hello All,

(Platform Game) Is there a way to get my enemy to die a certain way? Meaning, I would like for the enemy to collide with the “Player”, enemy flatten when hit, then enemy delete.

Is this possible and how could I achieve this?

Thanks :smiley:

An easy way, so you don’t have to modify all the enemy related events, could be to create a new object “EnemyDeath”, with the animation of the enemy death. When you kill an enemy, place this EnemyDeath object on its location, and then delete the enemy:

Conditions: Conditions to kill an Enemy Actions: Create object EnemyDeath at Enemy.X() ; Enemy.Y() Delete object Enemy

If you want to use this EnemyDeath for multiple enemies, you can add a death animation per enemy type. To link the death animation to the enemy being killed, add a variable “Death_Animation” to each object, storing the animation to be played by the EnemyDeath object:

Conditions: Conditions to kill an Enemy Actions: Create object EnemyDeath at Enemy.X() ; Enemy.Y() Do = Enemy.Variable(Death_Animation) to the current animation of EnemyDeath Delete object Enemy

For some reason I can’t get the animation to work :confused:

Here is a picture of my event. Am I doing this right?

If you are using the action to set animation by name, you have to use quotes around, because the name is a string (“Death”) :slight_smile:

Although Lizard-13’s way is the best one for flexibility (as it will work with any kind of death animation, not just squashing), if you didn’t want to create death sprites for every enemy type you could use scaling to squash the enemy.

In your “player is in collision with enemy” event, add the following action (from Sprite>Size>Scale on Y axis):

Do -10*TimeDelta() to the height’s scale of enemy

Then add a new event that checks how small the scale has got and deletes the object:

The height’s scale of enemy is <0.3 | delete object enemy

You will need to adjust the origin of the enemy object to be at the bottom left, rather than the usual top left, otherwise it will squash upwards.

One advantage with this approach is that you can create a group called enemy , put all your enemy objects in that and they will all be squashed with the same two events, rather than having to create new events and new animations for every type of enemy.

I’ve attached an example to this post using a modified version of the basic platformer, where you now squash platforms when you jump on them. It looks like the forum doesn’t allow .json files to be attached, so rename .txt to .json after downloading and put it in the Examples folder within GDevelop’s folder in Program files (x86).
Basic platformer - Squash.txt (23.8 KB)

That one is ok, I want to note a little problem with this last approach: you have to add an extra condition to every enemy related condition, checking the enemy scale, because you don’t want to be damaged by a death/getting squashed enemy :exclamation:

Yes, it does have some weaknesses, although I think if you tune the values just right it should always get squashed and disappear quickly enough not to cause problems. On the other hand, if you set the scaling step too low, then the enemy doesn’t get fully squashed before you “fall through” it. :astonished:

Thanks for the help. However I could not get this to work for me :neutral_face:

Could I have the “Enemy” preform an death animation first then after 1 second the “Enemy” get deleted?

If so, how do I put a timer on an object?

You can do that too, and you don’t need a timer, there is a condition to check if the current animation has finished. It would look like this:

[code]Conditions: Wiz_Kid is in collision with Alien
Actions: Set animation of Alien to “Death”

Conditions: Animation of Alien is “Death”
Animation of Alien as finished
Actions: Delete object Alien[/code]

Need to use object variable, I have an example for that, check this:
gametemplates.itch.io/template-instance-timer

That’s true in case you just want to wait until the end of an animation, but If the dead animation is a single frame, without a timer it is going to be deleted immediately I think.

That worked! Thanks. :slight_smile:

1 Like