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

player shakes when first touching the ground

A

Alsis World

Guest
when ever i jump and land on the ground the player character shakes for a second while touching the ground, here's my entire code if it's not in gravity or y collision:

////Movement

///Horisontal movement

move = keyboard_check(ord("D")) - keyboard_check(ord("A"));

hsp = move * movespeed;
x = x + hsp;

///Vertical movement

if (keyboard_check(vk_space)){
vsp = jumpspeed;
}

///Collision

//X Collision

if (place_meeting(x + hsp, y, obj_neutral_ground)){
x = x + sign(-hsp)
hsp = 0
}

//Y Collision

if (place_meeting(x, y + vsp, obj_neutral_ground)){
y = y + sign(-vsp);
vsp = 0;
}

///Gravity

if (vsp < 5 and not place_meeting(x, y + 1, obj_neutral_ground)){
vsp = vsp + grav;
}
y = y + vsp;
 

JasonTomLee

Member
At first glance, you set the y-axis twice. Once in the Y Collision and the other in the gravity code. This may cause some janky movement!

Try centeralizing the vertical speed into one variable & then apply it to the x-y coordinates.

var grav = 4;


//Y Collsion
if ( place_meeting( x,y+ vsp, obj_neutral_ground )){
vsp = 0;
} else {
//Gravity
vsp = grav;
}

// Apply Movement
y+=vsp;
 
Top