• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GML my jump doesnt work

so basically when I jump my character never comes down ):
no hate plz , and don't bully me for being a noob.
code:
(all in a google doc)

plz helpful comments.
 

Arconious

Member
So I copied the code over verbatim to a test project, and after a bit of tinkering around, got it working.

Main problem is in this whole block:
GML:
if (place_meeting(x, y + 1, oBlock))
{
    // we're touching the ground
    vspd = 0;
    jumping = false;
    falling = false;

    if (!duckKey)
        ducking = false;

    // if the player wants to jump
    if ((jumpKey || jumpKeyAlt) && !duckKey)
    {
        jumping = true;
        vspd = -jspd;
    }
}
else
{
    if (ducking)
    {
        vspd += grav * 4;   
    }
    else
    {
        if (vspd > termVelocity)
            vspd += grav;
                
            if (sign(vspd) == 1)
                falling = true;
    }
}
First thing: Notice you are only setting vspd if you are "ducking" OR if "vsp is greater than termVelocity". Because of this, vspd never has grav applied to it, unless the player hits the down/ducking button. You need to be applying gravity regardless of whether ducking is true or not.

Second thing: remember that you are setting vspd to a *negative* number when you jump! So in your jump check, you are saying "if vspd is greater than 0, jumping is true"... however, you mean the opposite of that: if vspd is less than 0, then jumping is true.

Also, you gotta keep in mind how you ask for help, as it'll impact whether people reply or not! People are less likely to respond if you double-bump and plead without showing diligence on your own part. Just future advice!
 
So I copied the code over verbatim to a test project, and after a bit of tinkering around, got it working.

Main problem is in this whole block:
GML:
if (place_meeting(x, y + 1, oBlock))
{
    // we're touching the ground
    vspd = 0;
    jumping = false;
    falling = false;

    if (!duckKey)
        ducking = false;

    // if the player wants to jump
    if ((jumpKey || jumpKeyAlt) && !duckKey)
    {
        jumping = true;
        vspd = -jspd;
    }
}
else
{
    if (ducking)
    {
        vspd += grav * 4;  
    }
    else
    {
        if (vspd > termVelocity)
            vspd += grav;
               
            if (sign(vspd) == 1)
                falling = true;
    }
}
First thing: Notice you are only setting vspd if you are "ducking" OR if "vsp is greater than termVelocity". Because of this, vspd never has grav applied to it, unless the player hits the down/ducking button. You need to be applying gravity regardless of whether ducking is true or not.

Second thing: remember that you are setting vspd to a *negative* number when you jump! So in your jump check, you are saying "if vspd is greater than 0, jumping is true"... however, you mean the opposite of that: if vspd is less than 0, then jumping is true.

Also, you gotta keep in mind how you ask for help, as it'll impact whether people reply or not! People are less likely to respond if you double-bump and plead without showing diligence on your own part. Just future advice!
Thank you so much! I'll work on it, but I'll miss seeing my horse yeet itself into the stratosphere.
 
Top