Roblox physics sleeping too much?

External Media

The body force does not apply its upward force until the hrp has an initial velocity

local plr=game:GetService'Players'.LocalPlayer
local char=plr.Character or plr.CharacterAdded:Wait()
wait(1)
local hrp=char:WaitForChild'HumanoidRootPart'

local bf=Instance.new'BodyForce'
bf.Parent=hrp

game:GetService'RunService'.Heartbeat:Connect(function(dt)
	local totalmass=0
	for _,p in next,char:GetDescendants()do
		if p:IsA'BasePart'then
			totalmass=totalmass+p:GetMass()
		end
	end
	bf.Force=Vector3.new(0,totalmass*workspace.Gravity,0)*10
end)

Well it doesn’t have to be in a loop

It happens in APS, two player local server, my windows 10 computer, and my friend’s windows 10 computer
zzz.rbxl (14.3 KB)

I think it is also the reason my grappler will hopelessly fail

6 Likes

use vector force + attachment to avoid broken physics sleeping bugs

stop use bodyforce/gyro/whatever

local plr=game:GetService'Players'.LocalPlayer
local char=plr.Character or plr.CharacterAdded:Wait()
wait(1)
local hrp=char:WaitForChild'HumanoidRootPart'

local at = Instance.new("Attachment")
at.Parent = hrp
at.CFrame = hrp.CFrame

local vf = Instance.new("VectorForce")
vf.Parent = hrp
vf.Attachment0 = at
vf.RelativeTo = "World"
vf.ApplyAtCenterOfMass = true

game:GetService'RunService'.Heartbeat:Connect(function(dt)
	local totalmass=0
	for _,p in next,char:GetDescendants()do
		if p:IsA'BasePart'then
			totalmass=totalmass+p:GetMass()
		end
	end
	vf.Force=Vector3.new(0,totalmass*workspace.Gravity,0)*10
end)

this code probably does what you want it to do

2 Likes


@jody7777, good job sending me to space.


Tested something, was this somewhat close to the intended result? Also I am missing what the goal is.

2 Likes

What are you supposed to use instead of a BodyVelocity? edit: and BodyThrust

@Operatik roblox sleeps instead of sending you to space on spawn

Why is there a yield(aka wait(1)) then?

Removing it should solve it. The script works fine even if it’s removed.

Already flying into space. lol

Because it should work either way
(Even when your speed is 0)

This is the Roblox bug I am reporting

When the velocity is 0 on Y, it does not accelerate and makes you stay on the ground, until you jump, fall or anything with velocity on Y.


Removing the wait(1) and spawning will cause the player to fly up immediately, due to the fact the player started with a velocity down. BodyForce causes the cancelling of gravity and there was additional acceleration up, causing player to fly.

BodyVelocity recommended combined with BodyForce to nullify gravity. Then you can have a constant speed up from BodyVelocity while BodyForce stops the gravity from ‘pulling’ the player down.