# Adding Leniency to Jumping Mechanic

I have written some jumping code for my player in a platformer game. At the moment it has some basic logic which says that the player can jump if he is on the ground. The pseudocode looks something like this:

### Input Handling ###
if(jumpButtonPressed){
if(onGround){
jump
}
}

### Player Update Loop ###
onGround = false
movePlayer
resolveCollisions
if(player collided with ground){
onGround = true
}


This works fine for basic static tile levels, but when the player is standing on a descending platform, or moving down a downward slope for instance, it becomes very difficult to jump. The reason for this (in the case of the descending platform) is that the platform has moved from underneath him in that frame, so for that moment he is not actually colliding with the ground, and therefore the condition to be able to jump is not fulfilled.

Is there a general way to add some leniency into the jump mechanic so that the player can jump even if they are not technically on the ground for that exact frame? This seems like it should be quite a common problem but I cannot seem to find any similar questions on stackexchange or google.

• Sounds more like you need to clean up your collision detection with the player and the ground. Or make a separate slightly larger bounding box that acts as a collision detector for the player jump. – MichaelHouse Oct 16 '13 at 14:24