GMS 2 2-D Platformer Jump Animation Issue

The issue: even if I change the speed values, the jumping animation remains a constant speed. The walking animation I can control just fine.

[UPDATE: AS IT TURNS OUT, THE PROBLEM IS ENTIRELY DIFFERENT]

It's not that the animation frame stays a constant speed, I tested a different sprite and as it turns out, it only plays the second frame and leaves out the rest.

Step code:
Code:
// Get input
key_Left = -keyboard_check(vk_left); key_Right = keyboard_check(vk_right); key_Jump = keyboard_check_pressed(vk_up);

// Use input
move = key_Left + key_Right; hsp = move * moveSpeed; if (vsp < 10) { vsp += grav; };

if (place_meeting(x, y + 1, obj_jwall)) { vsp = key_Jump * -jumpSpeed }

if (key_Jump) && (place_meeting(x+1,y,obj_jwall) || place_meeting(x-1,y,obj_jwall))
{
vsp = key_Jump * -jumpSpeed;
}
// H Collisions
if (place_meeting(x + hsp, y, obj_jwall)) { while (!place_meeting(x + sign(hsp), y, obj_jwall)) { x += sign(hsp); } hsp = 0; } x += hsp;

// v Collisions
if (place_meeting(x, y + vsp, obj_jwall)) { while (!place_meeting(x, y + sign(vsp), obj_jwall)) { y += sign(vsp); } vsp = 0; } y += vsp;
   
// Animations
if (!place_meeting(x,y+1,obj_jwall))
{
 sprite_index = sp_jplayerjump;
 image_speed = 0;
 if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
 image_speed = 1;
 if (hsp == 0)
 {
  sprite_index = sp_jplayer;
 }
 else
 {
  sprite_index = sp_jplayerwalk;
  image_speed = .15;
 }
}

if (hsp != 0) image_xscale = sign(hsp);
 
Last edited:

Kyrieru

Member
jump speed is the movement speed

image_speed is the animation speed, and you have it set to 0 when in the air.
 
jump speed is the movement speed

image_speed is the animation speed, and you have it set to 0 when in the air.

Im aware that its the value of image_speed that I need to change.

my problem was that even if I change it, it doesn't change the actual speed of the animation
 

Slyddar

Member
If you open the sprite for walk, up the top is where the speed is set. image_speed = 1 will run the sprite at the speed indicated there. I was just wondering if that is set to zero for some reason.

Note too, if you are changing sprites, you need to ensure you are setting the image_index to 0 as well, otherwise you may skip some frames.
 
If you open the sprite for walk, up the top is where the speed is set. image_speed = 1 will run the sprite at the speed indicated there. I was just wondering if that is set to zero for some reason.

Note too, if you are changing sprites, you need to ensure you are setting the image_index to 0 as well, otherwise you may skip some frames.
alright I think I got it, I also found out that I needed to change the image_index = 1 for the jumping animation in this part to the actual sprite index


Code:
if (!place_meeting(x,y+1,obj_jwall))
{
 sprite_index = sp_jplayerjump;
 image_speed = 0;
 if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
 
Top