How to calculate how many studs a player can jump based on JumpPower

How can I calculate how many studs a player can jump based on JumpPower?

Ex:
a player jumping at 50 jumpPower jumps at a peak point of 1 stud, etc.

15 Likes

JumpPower^2 = 2 * workspace.Gravity * height

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

44 Likes

Splendid, thank you.

4 Likes

May I ask, why is it multiplied by 2. I would need some further explanation on this. Even my physics teacher did not know.

1 Like

The formula come from projectile motion in the special case where theta = 90 degrees (straight up).

For more info refer to: Projectile motion - Wikipedia

The factor 2 comes from the fact that the negative acceleration downward (the gravity) is integrated from g * t to 1/2 * g * t^2 to get the distance against t, and then if you work that out for the t for the heighest point, that 1/2 is worked away by multiplying the right-hand-side by 2 above/below the line.

You can check the wikipedia article for a step-by-step on this.

3 Likes

But that cant be right because

workspace:CalculateJumpHeight(workspace.Gravity, 50)

returns exactly 7.1585116386414

The formula is “right” for height of parabolas in the real world. Maybe the Roblox engine is adding in another factor that changes the result slightly. Unfortunately it’s not documented so you’ll have to estimate that factor yourself. Feel free to share your findings on this thread later.

EDIT: looks like there is a difference between throwing up a brick with a certain impulse velocity compared to a player character jumping. It’s possible a player character is holding the jump velocity for a longer period of time, therefore increasing the jump height beyond what the initial impulse gives it.

Projectile motion is vertical motion + horizontal motion so why is it being used here? Surely you should be using vertical motion. Projectile motion would be for calculating how far the player can jump based on walkspeed gravity and jumppower ie workspace: CalculateJumpDistance

1 Like

As above, you can use the same formulas for theta = 90 degrees, see the Wikipedia article.

For parabolas where the player is also moving, you use vy = jump power and vx = walkspeed. For standing still and jumping, vx = 0, but vy is always the jump power.

The problem here is that it is likely the case that the engine propels the player upward for the full jump power for multiple frames rather than as an impulse, which means the formula as-is doesn’t work, you need to calculate the position after N frames with the full jump power and then use the parabola formulae from there. I don’t have the numbers here exactly, try it out and see what you find, or just try to avoid doing manual jump height / power calculations entirely by setting your desired properties on the Humanoid/StarterPlayer.

I managed to negate the error in the calculation by doing the following

local ErrorFactor = nil

function CalcTrueJumpHeightFromPower(Power)
	if ErrorFactor == nil then
		local Humanoid = Instance.new("Humanoid")
		local TrueHeight = Humanoid.JumpHeight
		local CalculatedHeight = (Humanoid.JumpPower ^ 2) / (2 * workspace.Gravity)
		ErrorFactor = TrueHeight/CalculatedHeight
		Humanoid:Destroy()
	end
	return ((Power ^ 2) / (2 * workspace.Gravity) * ErrorFactor)
end