✓ Accepted answer
The JumpPower property defines the initial Y velocity of the character when the jump is activated. This then comes down to rather basic physics. I set up a little ugly experiment that can give quite accurate results.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.Jumping:Connect(function()
local v0 = Vector3.new(0, humanoid.JumpPower, 0)
local a = -workspace.Gravity
local t = (v0 / -a).Y
a = Vector3.new(0, a, 0)
local x0 = character.PrimaryPart.Position
local v0 = character.PrimaryPart.Velocity
local x = x0 + v0*t + (1/2)*a*t^2
print("EXPECTED", x)
local tab = {}
local startPos = character.PrimaryPart.Position
local connection = game:GetService("RunService").Heartbeat:Connect(function()
tab[#tab + 1] = character.PrimaryPart.Position.Y - startPos.Y
end)
wait(t*2)
connection:Disconnect()
print("PEAKED AT", startPos + Vector3.new(0, math.max(unpack(tab)), 0))
end)
Forgot to mention; the Jumping event for some reason fires twice and it first does the calculations with incorrect values. But this should point you to the right direction.
To calculate the required JumpPower to reach a certain height, you can first calculate the potential energy (mgh) which when the jump starts is turned into kinetic energy ((1/2)mv^2). From there you can solve for v, which is the required velocity. You can also use this to calculate the height if you know the JumpPower.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local part = workspace.Part
local g = workspace.Gravity
local m = 0 do
for _, part in next, character:GetDescendants() do
if part:IsA("BasePart") then
m = m + part:GetMass()
end
end
end
humanoid.Jumping:Connect(function()
local footPos = character.PrimaryPart.Position - Vector3.new(0, 2, 0)
local h = (part.Position + Vector3.new(0, part.Size.Y/2, 0) - footPos).Y
local v = math.sqrt(2) * (math.sqrt(m * m*g*h) / m)
humanoid.JumpPower = v
end)
2 comments
2.5-2.6 jumppower would let you jump 1 stud above surface with no animation (froze my char animation).
The issue is that I don't think its a linear model