Character is always facing left once any key on the keyboard is not pushed anymore.

Meatbaby

Member
Hello, i'm trying to assign basic movement/collision in my game but i'm having a weird problem I can't seem to pinpoint. All I have is one character and another object to test collision against.

For some reason, whenever I release a key the left facing sprite is what is instantly snapped to. Am I missing something that points towards going to the left facing sprite in the code below?

GML:
// Update Player Inputs
input_left = keyboard_check(vk_left) || keyboard_check(ord("A"));
input_right = keyboard_check(vk_right) || keyboard_check(ord("D"));
input_up = keyboard_check(vk_up) || keyboard_check(ord("W"));
input_down = keyboard_check(vk_down) || keyboard_check(ord("S"));
input_run = keyboard_check(vk_shift);

// Alter Player Movement Speed
if (input_run && ply_allowrun = true) {
    ply_speed = ply_run;
} else ply_speed = 2;

//Player Movement
if (input_down && place_free(x, y + collision_speed)) {
    y += ply_speed;
    image_speed = ply_speed / 2;
    sprite_index = ply_forwardwalk;
}

if (input_left && place_free(x - collision_speed, y)) {
    x -= ply_speed;
    image_speed = ply_speed / 2;
    sprite_index = ply_leftwalk;
}

if (input_right && place_free(x + collision_speed, y)) {
    x += ply_speed;
    image_speed = ply_speed / 2;
    sprite_index = ply_rightwalk;
}

if (input_up && place_free(x, y - collision_speed)) {
    y -= ply_speed;
    image_speed = ply_speed / 2;
    sprite_index = ply_backwardwalk;
}


//Stop animation on key releases.
if (keyboard_check(vk_nokey)) {
    image_speed = 0;
    sprite_index = 0;
}
 
Top