how to make a animation play once

yes hello idk if im plain stupid ive been looking around for hours for this answer and its really simple

i want to press a button like E

when i press the button my objects sprite play the animation once and then stop and go back to normal

just once

anyone can help?
 

Vusur

Member
What does "back to normal" mean? Different sprite but still animated (loop animation)? Same sprite but the first image without animation?
 

Vusur

Member
Add Event -> Key Pressed -> Letters -> E

GML:
image_speed = 1; //or what speed you want;
Add Event -> Others - Animation End

GML:
image_index = 0;
image_speed = 0;
Is the easiest way.

Alternative for key pressed event:

Step event:

GML:
if(keyboard_check_pressed(ord("E"))) image_speed = 1;
cheers
 

ETHC33

Member
I don’t know if you’re trying to do melee attacks or not, but you could ignore everything about hitting the enemy and this is exactly what you need.
It shows state machines and gives you a great animation_end() script.

( also quick tip in the attack script change image index = 0; to image_speed = 1; so you can to the animation while jumping or in the air
 
Add Event -> Key Pressed -> Letters -> E

GML:
image_speed = 1; //or what speed you want;
Add Event -> Others - Animation End

GML:
image_index = 0;
image_speed = 0;
Is the easiest way.

Alternative for key pressed event:

Step event:

GML:
if(keyboard_check_pressed(ord("E"))) image_speed = 1;
cheers
any alternatives for animation end?
 
Top