How to Calculate Jump Force in Godot

Опубликовано: 07 Август 2026
на канале: Thomas Yanuziello
744
51

You have a character that can jump in your game, either in 2D or 3d.
But when you press the jump button, an arbitrary amount of jump force is applied to the character's y velocity, moving them upward.
But you want your character to be able to jump to a specific height, so how much force should you apply to the character to reach that height?

Start by exporting a private variable for the character's jump height.
Next, change the jump force from a constant to a private variable.
Then in the ready function, calculate its value using a mathematical formula:
_jump_force = sqrt(abs(_jump_height * gravity * 2))

In 3D, you'll simply be able to set the character's y velocity to the jump force, since positive is up.
In 2D, you'll need to set the character's y velocity to the negative of the jump force instead, since up is negative.

Patreon:   / tyanuziello  
Discord:   / discord  
Udemy: https://www.udemy.com/course/build-a-...
Skillshare: https://skl.sh/497zNpO

2D assets made by Pixel Frog
https://pixelfrog-assets.itch.io/trea...
3D assets made by KayKit
https://kaylousberg.itch.io/kaykit-ad...