Implementing better jump

Godot Version



Hello! I’m developing a 2d platformer, and I want to implement very good jump, which would be:

  1. Responsive
  2. Great feeling
  3. Intuitive

I already implemented coyote time and jump buffering, but I want to make jump more natural by increasing gravity when falling. I watched many tutorials on YouTube, but code from those just didn’t seems to work in my case, because it just causing no errors, but I’m just facing a grey screen when starting the project. So, does someone have any simple code to increase jump gravity when player starts falling, and after a short period of time make it fall gravity?
P.s. It may be not the best solution when trying to achieve that type of jump arc with smooth increasing of height and more fast decreasing, so if anyone have any better solutions, I will be very glad to hear them

You can modulate the gravity by multiplying it directly

var slowfall: bool = velocity.y > 0 and Input.is_action_pressed("jump")

if not is_on_floor():
    # 3/4 gravity if holding jump
    velocity.y += gravity * delta * (0.75 if slowfall else 1)

It’s okay, but i don’t want my player keep pressing jump, also this leads to exploiting, because of the possibility of tweaking the gravity. I want it to be independent of the player.

This talk, “Math for Game Programmers: Building a Better Jump” is a must to watch in order to build better jump systems.

Here’s the slides in PDF form.

1 Like