• 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 flawed jump collision

F

fxokz

Guest
For some reason whenever I jump the player either gets too deep into the ground, floats above it or collides perfectly with it. It varies every time I jump. It has to be because of the fact that the gravity variable I use is a decimal value. when I change it to a whole number everything goes smooth.

edit: okay so I was wrong. I'm not exactly sure why this is happening

any suggestions on how I could rewrite this?
Code:
//fall
if (vsp < 10)
{
vsp += global.grav;
}

//jump
if (place_meeting(x, y+1, par_boundary))
{
    vsp = (key_jump * -jump_speed);
}
Code:
//vertical collision
if place_meeting(x, y+vsp, par_boundary)
{
    while(!place_meeting(x, y+sign(vsp), par_boundary))
    {
        y += sign(vsp)
    }
    vsp = 0;
}
y += vsp;
 

Tthecreator

Your Creator!
what if in your second code example you round y+vsp?
The rest all seems to be using sign() so that shouldn't be an issue. That's the only place I see it being a potential problem.
 
Top