• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

animation before instance_destroy (help)

kureoni

Member
i have this code for the enemy IA but when it dies the instance is destroyed without running the animation before
how do i change that?

GML:
mp_potential_step(obj_player.x, obj_player.y, spd, obj_colision)

if (life <= 0){
    sprite_index=spr_enemy1_death
    instance_destroy()
}
 

AnotherHero

Member
You're having the sprite_index change the same frame you destroy the instance.

You need to do an image_index check! Like
GML:
if (image_index > image_number) {
    instance_destroy();
}
 

DPMlofty

Member
Hey, you can do something like this
GML:
if(life <= 0){
    sprite_index = spr_enemy1_death;
    if(image_index >= "maximun numbers of frames of the death sprite"){
        instance_destroy();   
    }
}
 

kureoni

Member
You're having the sprite_index change the same frame you destroy the instance.

You need to do an image_index check! Like
GML:
if (image_index > image_number) {
    instance_destroy();
}
it runs the animation on a loop and it does not destroy the instance
some instances keep following the player, some stop etc
 
Top