Legacy GM [State Machine] Crouch Animation Loop

How do I stop my crouch animation at the last frame? I tried setting it up like this and it still loops.


Code:
// Get Input
scr_jpgetinput();

// Crouch Animation
sprite_index = sp_jplayercrouch;
image_speed = 0.4

if sprite_index = sp_jplayercrouch && image_index = 6
{
image_speed=0
}

// State Transitions
if keyboard_check_released (vk_down)
{
state = states.normal;
}

// Collisions
scr_jpcollisions();

// flip
scr_flip();
 

pipebkOT

Member
Use the animation end event. It's in:

Add event >>others >animation end

And paste

Code:
if sprite_index = sp_jplayercrouch
{
image_speed=0
Image_index=6
}
 

pipebkOT

Member
this is the problem

// Crouch Animation
sprite_index = sp_jplayercrouch;
image_speed = 0.4
since you have it in the step event, image_speed will always be 0.4


maybe if you add a variable, would work better

create event
Code:
crouched=false

step event
Code:
if crouched  !=true
{
// Crouch Animation
sprite_index = sp_jplayercrouch;
image_speed = 0.4
crouched=true
}
 
Last edited:
Top