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

SOLVED Dash Animation Suddenly Cancels

So, i'm creating a Dash function for my game and it's very simple, however, for some reason it's stopping before intended.
Basically it works most of the times, but sometimes it stops right at the beggining, or in the middle of it.

This is how i start the Dash.

if (mouse_check_button_pressed(mb_left)) {
state = playerstates.dash; // This is how i change the character states from a enum called playerstates.
instance_destroy(obj_Run_Marker); // My character moves towards this marker obj when it's instanced, so i destroy it to override the normal move into dash.
move_towards_point(mouse_x, mouse_y, playerDashSpeed);
}

This is the dash state / sprite render.

switch (state) {
case playerstates.dash:
sprite_index = spr_Dash;
if(image_index >= 6) { // My animation has 7 frames, but since it starts at 0 if it gets equal to 6 or higher than 6, the dash ends.
state = playerstates.idle; // Goes back into idle. When idle, speed is set to 0.
}

Since there's nothing instancing it back to idle and when dash state occurs it can only go back to idle when the animation ends, i tried debbugin the image_index and i got something really strange:

First Try // Animation Happens Normal //
1
1.33
1.67
2
2.33
2.67
3.00
3.33
3.67
4.00
4.33
4.67
5
5.33
5.67
6.00

Second Try // Problem Occurs
6.83

Third Try // Problem Occurs Again
6.67

For some reason that i really can't understand, the image_index is starting above 6 and this makes it go back to idle.
I tried to set image_index back to 0 in the IF that checks image_index >= 6, but it didn't really helped since it's really starting above 6 and it throws me back to idle.

Btw, if this can have any relation with FPS, my animation speed is 20 frames , the game is running on 60 frames.

Thx in advance!
 
Last edited:
You need to set the image_index to 0 before switching to the dash state.
Just did that hahaha
It seems that image_index is always running with whatever sprite it's rendering so when my idle animation was in a bigger frame it would not work since it would try to render my dash sprite on a higher value than it has.

But thanks anyways man!
 
Top