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
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.
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
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.
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