Player not moving

My character does not move when I run the program. I only have a step event:
Code:
//input
left = keyboard_check(ord("A"));
right = keyboard_check(ord("D"));
jump = keyboard_check_pressed(vk_space);

//Movement
var move = right - left;

hsp = move * walksp;

vsp = vsp + grv;

//Horrizontal collision
if (place_meeting(x+hsp,y,ocity)){
    
    while (!place_meeting(x+sign(hsp),y,ocity)){
        
        x = x + sign(hsp);
    }
    hsp = 0;
}
x = x + hsp;

//Verticalcollision
if (place_meeting(x,y+vsp,ocity)){
    
    while (!place_meeting(x,y+sign(vsp),ocity)){
        
        y = y + sign(vsp);
    }
    vsp = 0;
}
y = y + vsp;

//jump
if (place_meeting(x,y+1,ocity)) and (jump){
    vsp = -10;
}

if (place_meeting(x,y+1,oplat1)) and (jump){
    vsp = -10;
}

if (place_meeting(x,y+1,oplat2)) and (jump){
    vsp = -10;
}


//Animation

//jump animation

if (!place_meeting(x,y+1,ocity)){
    
    sprite_index = judyjump;
    
}

else{
    if (hsp == 0){
        sprite_index = judystand;
        
    }
        else{
        sprite_index = judyrun;
    }
}

//basic attack
if (mouse_check_button(mb_left)) sprite_index = judyattack;

//crouch
if (keyboard_check(vk_shift)){
    sprite_index = judysit;
    

}

//facing direction
if (hsp != 0) image_xscale = sign(hsp);
 

AnotherHero

Member
If you only have a step event, when are walksp and grv being set? If your character has no walksp, your speed is either (1 * 0) = 0, or (-1 * 0) = 0.
 

sinigrimi

Member
set the desired values in create event, such as hsp, grv and so on. Your player cannot take a value from a variable without a value
 
Last edited:
Top