Keeping fall speed constant

Hello! So I am currently making a game where falling at the same speed overtime is critical.

It seems like when you fall in Roblox the fall speed accelerates overtime. I dont want this, I just want a linear fall speed where it stays the same and does not decelerate or accelerate as you fall.

If possible, I would also like the fall speed to increase by a certain value when the key ‘W’ is is held down, then when the key is unpressed the fall speed then returns to its original linear speed.

As you can tell I am very unexperienced with the gravity property and BodyVelocity etc. So if anyone could point me in the right direction that would be briliant.

Thank you for your time.

7 Likes

To control the fall speed, you can edit the Y value of HumanoidRootPart.Velocity. A falling velocity would be negative.

You would want to pair this with something checking the HumanoidStateType to find if the player is falling or not.

How would I go along doing that? I’ve tried changing the humanoid velocity but the fall speed still accelerates.

You could use BodyVelocity, it maintains a constant velocity for a part.

You could try using HumanoidRootPart:GetPropertyChangedSignal("Velocity") and every time it changes do a check to see if the user is falling. If they are set their velocity. As for holding the W key to speed up, you could look towards UserInputService.

1 Like

If you want to limit the speed that an object falls at, you can check the velocity every physics tick and keep it at an acceptable level.

-- local script in StarterCharacterScripts
local maxFallingSpeed = -30
local part = script.Parent.PrimaryPart -- the vertical velocity of this part shall not go lower than maxFallingSpeed

game:GetService("RunService").Stepped:Connect(function()
	local v = part.Velocity
	if v.Y < maxFallingSpeed then
		part.Velocity = Vector3.new(v.X, math.max(maxFallingSpeed, v.Y), v.Z)
	end
end)

The character will still have a parabolic arc to its jumps, as normal, but it won’t fall faster than 30 studs per second.

12 Likes

Hmm, not sure, maybe use a BodyVelocity like ElusiveEpix said, then make the MaxForce on Y as high as possible and add a negative Y velocity, the lower the velocity the higher the fall speed should be.

You are an absolute godsend! This works immaculately, thanks very much.

1 Like