Constant falling speed

Hello everyone!

How would i go on about making it so a player falling does not accelerate, but instead falls at a constant speed?

All ideas are appreciated!

1 Like

You can check the character’s velocity and keep changing it to the velocity you want.

1 Like

I’m not very experienced with Physics modifier instances, but maybe you could use a VectorForce with an equal acceleration to that of the workspace.Gravity property and then add a LinearVelocity to move it down on the HumanoidRootPart?

1 Like

in the game configuration you can easily modify it or else you could use vector force

This would merely make me fall slower, but in the end the character still accelerates. If i were to add a force to the player to counteract acceleration it would have to be squared just like acceleration is

1 Like

What do you mean? Force is mass * acceleration. Force is just acceleration relative to mass. So for example, applying the same force to a larger object would still accelerate it, just at a slower rate.

Gravity in and of itself is a force. If you simply use a force of, for example, 9.81 upwards (0, 9.81), it should in theory cancel out gravity.

Then, to make the player fall at a constant rate, (i.e. velocity) you can use a LinearVelocity. Although, you will need to set up Attachments which can be particularly annoyed to use

Well it would then only be 9.81 upward for the first second of the fall, and 19.6 for the next second and so on

-- StarterCharacterScripts

local maxSpeed = -30 -- Velocity

local HumanoidRootPart = script.Parent.HumanoidRootPart
local Humanoid = script.Parent:FindFirstChildOfClass("Humanoid")
local Run = game:GetService("RunService")

local freefall = false

Humanoid.StateChanged:Connect(function(old, new)
	if new == Enum.HumanoidStateType.Freefall then
		freefall = true
		print(freefall)
	else
		freefall = false
		print(freefall)
	end
end)


Run.RenderStepped:Connect(function()
	if freefall == true then
		local Velocity = HumanoidRootPart.Velocity

		if Velocity.Y < maxSpeed then
			HumanoidRootPart.Velocity = Vector3.new(Velocity.X, math.max(maxSpeed, Velocity.Y), Velocity.Z)
		end
	end
end)
3 Likes

That’s velocity. Velocity does not increase on its own over time.

Force (i.e. acceleration) increases the velocity over a certain period of time. F = m * (v-u)/t

I mean, gravity is a force. How can apply an equal and identical force against the other NOT result in an acceleration of 0?

(Keep in mind, you will need to account for the Player’s mass in the force as force is not just acceleration, but rather mass * acceleration)

Zero gravity script:

local Character = script.Parent
local mass = 0
for i,v in ipairs(Character:GetDescendants()) do
	if v:IsA("BasePart") then
		mass = mass + v:GetMass()
	end
end
local f = Instance.new("VectorForce")
f.Force = Vector3.new(0, mass*workspace.Gravity, 0)
f.Attachment0 = Character.PrimaryPart.RootRigAttachment
f.Parent = Character.PrimaryPart

Now change the velocity of the HumanoidRootPart when Humanoid.FreeFalling is true/false

1 Like

This physically would not work. If anything it would be BAD for the character.

I have a solution. You can create “local gravity” for the player and anything it has network ownership of if you set gravity to zero locally, and then use your OWN method of gravity. I would use LinearVelocities. They accelerate to a specific speed, and then stop when you reach that velocity.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local local_gravity = 15

game.Workspace.Gravity = 0 -- this will make you float but everything else will still have gravity

local attachment = Instance.new("Attachment", char:WaitForChild("HumanoidRootPart"))
local gravity = Instance.new("LinearVelocity", char.HumanoidRootPart)

gravity.Attachment0 = attachment
gravity.VelocityConstraint = Enum.VelocityConstraintMode.Line
gravity.LineDirection = Vector3.new(0, -1, 0) -- downwards vector unit
gravity.LineVelocity = local_gravity -- the force

-- this is all local!

It’s not tested, but I’m sure it will work. You can change the gravity constant to what’d you like. If you want to stop the gravity, disable the LinearVelocity.

This would not work either for the same reason. It’s way easier to use a Linear Velocity, because it attempts to maintain a certain velocity. You can change the speed.

(Sorry to be picky in advance, but)

Please refer to this post, the Velocity property is now deprecated

BasePart.Velocity and BasePart.RotVelocity are now deprecated (hidden from Properties window). There were multiple issues in their operation when dealing with a part and its assembly. For example, setting velocity on a part that isn’t a root part just doesn’t work, but it always reads the velocity of the specific part. The AssemblyLinearVelocity and AssemblyAngularVelocity properties, along with the new impulse functions, should provide all of the options necessary for setting specific velocities.


cc @Den_vers

Consider the version of the code above with Instance.new called with parent argument:

local wall = Instance.new("Part", workspace.Effects)
wall.Size = Vector3.new(10, 10, 1)
wall.CFrame = CFrame.new(x, y, z)

You may think that this is faster because you saved one assignment, but it’s actually much slower in this case. Here’s what happens:

  1. You create a Part with the CFrame of 0,0,0 and a default Size, and parent it to workspace.
  2. ROBLOX sets up property change listeners for replication, rendering, etc.
  3. ROBLOX queues a replication of a new instance with default values for the Size/CFrame
  4. ROBLOX updates physics contacts between this part and whatever is at the origin
  5. You set the part Size to 10,10,1
  6. ROBLOX queues a replication change for the Size
  7. ROBLOX updates physics contacts between this part and whatever is at the origin and overlaps with the part given the new dimensions
  8. You set the part CFrame to x,y,z
  9. ROBLOX queues a replication change for the CFrame
  10. ROBLOX updates physics contacts between this part and whatever is at the position x,y,z given the size 10,10,1

Try not to use any bad practices when you can please :wink:

3 Likes

This works, and it also makes a lot of sense why. Thank’s alot

As stated by @Jackscarlett Velocity is deprecated, I will try improve the script in a little bit to ensure Velocity isn’t used.

I did what @majdTRM said basically and it works fairly well.
Inside of StarterCharacterScripts:

local Character = script.Parent
local mass = 0
for i,v in ipairs(Character:GetDescendants()) do
	if v:IsA("BasePart") then
		mass = mass + v:GetMass()
	end
end
local f = Instance.new("VectorForce")
f.Force = Vector3.new(0, mass*workspace.Gravity, 0)
f.Attachment0 = Character.PrimaryPart.RootRigAttachment
f.Parent = Character.PrimaryPart

local lv = Instance.new("LinearVelocity")
lv.LineDirection = Vector3.new(0, 1, 0)
lv.LineVelocity = -10
lv.VelocityConstraintMode = Enum.VelocityConstraintMode.Line
lv.MaxForce = 10^4
lv.Enabled = false
lv.Attachment0 = Character.PrimaryPart.RootRigAttachment
lv.Parent = Character.PrimaryPart

Character.Humanoid.FreeFalling:Connect(function(bool)
	lv.Enabled = bool
end)

Test place:
Baseplate.rbxl (40.9 KB)

1 Like

It’s all good i can do that, thank’s alot again

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.