Help with this formula

I’m trying to calculate the maximum height in studs that a player can jump and I found this reply:

However I’m just not how to use this? Is JumpPower^2 a constant? It’s defined in the first line but it’s defined using a value that doesn’t exist until the second line. I didn’t want to necrobump the thread.

I’m sorry if I sound stupid, I’m just so confused with this

Here’s a similar thread I answered:

This JumpPower is a constant that is found in a property of the Humanoid object. It is the vertical velocity that your player jumps with. The maximum height is derived from that.

This has the same thing that’s confusing me:

h = (v0 ^ 2) / (2 * workspace.Gravity)
v0 = math.sqrt(h * 2 * workspace.Gravity)

h is first defined in a formula using v0, but then v0 is set in a formula using h

I’m probably being stupid, but I don’t know how I would implement this into a script because v0 would be nil??

1 Like

v0 is the Humanoid’s JumpPower.

So what does the second line do? What is h?

The second line is the same formula, just solved for v0.

2 Likes

Sorry, but what would h be in the equation?

h would be the highest point of the jump.

You can find the same formula here:
(Assume sin(theta) is 1 since we’re only focusing on the vertical component of the jumping.)

2 Likes

The equation he is using uses the law of conservation of energy I believe.
So the energy before the player jumps is equal to the energy after the player has reached its maximum jump height.

We start off with maximum potential energy… mass * gravity * height
Then go to maximum kinetic energy… 0.5 * mass * velocity^2

mass * gravity * height = 0.5 * mass * velocity^2
gravity * height = 0.5 * velocity^2

height = (0.5 * velocity^2) / gravity 
or
height = velocity^2 / (2 * gravity)

Im a bit confused about this what would the height be and what would the velocity be

Height is the maximum jump height of the player, so how far the player reaches in the sky before gravity starts pulling them down again.

Velocity in this case is the magnitude of the velocity used to lift the player off the ground. That means its a scalar value, and not a vector, I should have been more explicit with the naming, sorry.

Ill rewrite the equation for you using better terms, here…

height = humanoid.jumppower^2 / 2 * workspace.Gravity
-- Remember, height is the maximum height the player reaches in the sky when jumping before gravity starts pulling them down again.
1 Like

Alright thanks ill go try it out. Thanks it worked PERFECTLY

Reviving Old Thread but this formula doesn’t work.

 local height = PlayerHumanoid.JumpPower^2 / 2 * workspace.Gravity
                
 print(height)

 print(PlayerHumanoid.Parent:FindFirstChild("HumanoidRootPart").Position)

With that Formula, are the Y values supposed to match at the jumps peek since you are calculating for height?

Didn’t want to bump this but I’ll quickly explain to you why;
First off height is just a number, not taking in account your starting position; Its only suppost to tell you the maximum studs you will lift off the ground once you jump.
Secondly, the formula is wrong since without brackets it won’t calculate correctly.
The correct formula is:

local height = hum.JumpPower^2 / (workspace.Gravity*2)

The default maximum is 6.37, that is for JumpPower of 50.

If you’re trying to check when the player is at the peak of their jump you’d have to store their position before the jump and check until the position.Y is position.Y+height, which isn’t the best way to check if thats what you’re using it for.

EDIT: I actually tested this and it isn’t consistent, you’d probably have to do extra math to get it to work using the HRP’s position