• 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!

Legacy GM [State Machine] Crouch Animation Loop

A

AngelofGamin

Guest
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
}
 
A

AngelofGamin

Guest
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
}



still loops unfortunately, unless there's something I'm missing.
 

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