[Solved] Playing animation before deleting object (shooting game)

Hello everyone!

In my game I have this portion where the character shoots the enemy 3 times to kill it (then deleted). Or, the character collides with it and kills it (then deleted) while also sustaining damage.

But before the enemy is deleted I wanted it to play an animation (“Death”) first then delete it.

Now, my problem is the animation death can still collide with the bullet and replays the Death animation when it does, and can still also collide with the character and can drain my character’s health when a prolonged collision.

This is the Enemy is dead part of the code:

This is when my character collides with enemy:

1 Like

Maybe add this into Neu’s collision event?
image

Basically add an animation check and inverse it so that the damage happens only when the death animation isn’t playing. Same can be applied to the bullet’s collision event.

Tell me if it works

1 Like

It didn’t work :face_holding_back_tears: @Digitalstickmans

EDIT: Sorry, this works great, I just overlooked the other conditions.

1 Like

It’s deleting the health bar, so the next time around there’s nothing to pick so the other events probably aren’t going to be triggered. Try moving the animation has finished event 2 indentations to the left so it’s just a subevent of the is dead event.

2 Likes

I tried this:

My enemy is not deleted after it’s “dead” :face_holding_back_tears:

EDIT: I mean it deletes it after playing the Death animation but while the Death animation is playing and I hit it again it goes back alive and well to it’s default animation :face_holding_back_tears:

1 Like

Unless there’s another event changing the animation, this plus changing the collision event should work. Do you have any other events or behaviors that might be changing the animation? Maybe an idle or directional.

2 Likes

Maybe it’s this one:

Is there a way to not make the enemy “collide” with the bullet when it’s playing the Death animation? :face_holding_back_tears: and also when it’s playing the Death animation that it does not deal damage to my character anymore when my character collides with it? I’d really appreciate any suggestion

1 Like

It was mentioned previous, you can add a condition to make sure the animation is not “Death” or add the is dead condition and invert it so it’s basically is alive.

Conditions work like filters. You filter the objects that you want. In this case objects.thay are in collision and alive (inverted is dead)

2 Likes

I got it, it all works now. Thank youuuuu @Keith_1357 and @Digitalstickmans :smiling_face:

2 Likes