So I’m trying to make performant falling parts. When they stop moving completely (falling from ceiling then hitting the floor), they’ll be anchored to reduce physics lag.
I don’t really have a script, which I know is needed but the farthest thing I could come up with is this:
It doesn’t even work but what I’m trying to do is find a property that detects when something is still, CFrame, AssemblyAngular/LinearVelocity, etc and nothing seems to work.
local past = Vector3.new()
local current = part.Position
local isStill = false
game:GetService("RunService"):Connect(function()
current = part.Position
if (current - past).Magnitude < 0.01 then
isStill = true
else
isStill = false
end
past= part.Position
end)
For anyone else reading who wants to create performant falling parts (anchoring still parts for performance boost), I suggest adding a count system, so if the part bounces and the magnitude decreases insanely for even a short second, the part won’t get anchored mid air.
Incase I’m terrible at explaining, I’ll just post the modified script here:
local Part = script.Parent
local Past = Vector3.new()
local Current = Part.Position
local Count = 0
while true do
Current = Part.Position
if (Current - Past).Magnitude < 0.01 then
Count += 1
if Count > 3 then
Part.Anchored = true
Part.CanCollide = false
break
end
end
Past = Part.Position
wait(0.1)
end