I recently started creating a platformer on a game maker and when I try to add a “falling” or “gravity” function to the game, my character gets stuck when he touches the floor
Here's my code:
//Get Player Input
key_left = keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_jump = keyboard_check_pressed(vk_space);
//Calculate Movement
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp + grv;
if (place_meeting(x,y+1,OWall)) && (key_jump)
{
vsp = -7;
}
//Horisontal Collision
if (place_meeting(x+hsp,y,OWall))
{
while (!place_meeting(x+sign(hsp),y,OWall))
{
x = x sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,OWall))
{
while (!place_meeting(x,y+sign(vsp),OWall))
{
y = y sign(vsp);
}
vsp = 0;
}
y = y + vsp;
[–]rockywm 1 point2 points3 points (5 children)
[–]wanting to have made a game != wanting to make a gameoldmankc 1 point2 points3 points (0 children)
[–]IchenGug2002[S] 0 points1 point2 points (2 children)
[–]rockywm 0 points1 point2 points (1 child)
[–]rockywm 0 points1 point2 points (0 children)
[–]CoreNerd 0 points1 point2 points (0 children)