• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Legacy GM Player Character is no longer moving

G

Genoman21

Guest
I have been working on a basic platformer currently and just finally got the animation to play properly when the keys are pressed, but now my character won't while on the ground. It will jump, and i can move forward that way but as soon as it lands it will no longer move on the x-axis.

Here is my player objects code:
(code that pertains that is outside the player_obj:
hsp=0
movespeed=4)

"
//Get Player Input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);


//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav

if (place_meeting(x,y+1,obj_box))
{
jumps = jumpsmax
}
if (key_jump) && (jumps > 0)
{
jumps -= 1;
vsp = key_jump * -jumpspeed
}


//Horizontal Collision
if (place_meeting(x+hsp,y,obj_box))
{
if(!place_meeting(x+sign(hsp),y,obj_box))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;

//Vertical Collision
if (place_meeting(x,y+vsp,obj_box))
{
if(!place_meeting(x,y+sign(vsp),obj_box))
{
y += sign(hsp);
}
vsp = 0;
}
y += vsp;


//Animate
if (move!=0) image_xscale = move;

if (place_meeting(x,y+20,obj_box))
{
if (move!=0) sprite_index = spr_lind_walk; else sprite_index = spr_lind_idle
}
else
{
if (vsp < 0) sprite_index = spr_lind_idle; else sprite_index = spr_lind_idle
} "

i have no idea why it wont move anymore
 

obscene

Member
Sounds like you are getting 1 pixel into the floor. When checking vertical collisions the goal is to move until there is a collision at y+1, not y.
 
G

Genoman21

Guest
thanks, I found out that it was my idle animation sprite. adjusted the hitbox on it by 2 pixels and it fixed the problem (at leasts for now)
 
Top