• 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!

Legacy GM [Solved] Player Object shakes when moving vertically in any direction ( jumping/falling )

X

XenoMustache

Guest
The object I have created to test player movement appears to 'stutter' when jumping or falling. Disregard the shakiness of the GIF below ( due to low quality recorder ), the GIF still gets the point around, as you can see the obvious shaky movement of the player object as it moves up or down. I have tried changing the view, resizing the room, setting my code to the end step even; none of that seems to help.


Code for player control ( includes physics )
Code:
///Control Player Movement
//Get the player's input
key_right = keyboard_check(ord('D'));
key_left = -keyboard_check(ord('A'));
key_jump = keyboard_check_pressed(vk_space);
//React to inputs

friction = 0.5
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;

if (place_meeting(x,y+1,obj_wall))
{
    vsp = key_jump * -jumpspeed
}

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

//Vertical Collision
if (place_meeting(x,y+vsp,obj_wall))
{
    while(!place_meeting(x,y+sign(vsp),obj_wall))
    {
        y += sign(vsp);
    }
    vsp = 0;
}
y += vsp;
 
X

XenoMustache

Guest
However, rounding the gravity appears to have worked. Thank you for your help, I never would have thought to try rounding it.
 
Top