-
What do you want to achieve?
I’m trying to make a basic custom physics engine with balls that collide with parts -
What is the issue?
The ball clips through the floor -
What solutions have you tried so far?
I’ve tried decreasing gravity
-- Ball collider physics
-- ToldFable 2023
local physicsParts = workspace.Folder:GetChildren()
for t=1,200 do wait()
for i,v in ipairs(physicsParts) do
if not v:GetAttribute("ToldFable_Velocity") then
v:SetAttribute("ToldFable_Velocity",Vector3.zero)
end
if not v:GetAttribute("ToldFable_Gravity") then
v:SetAttribute("ToldFable_Gravity",Vector3.new(0,-0.0001,0))
end
local CustomGravity = v:GetAttribute("ToldFable_Gravity")
local CustomVelocity = v:GetAttribute("ToldFable_Velocity")
local Params = OverlapParams.new()
Params.FilterType = Enum.RaycastFilterType.Blacklist
Params.FilterDescendantsInstances = {v}
local touchingParts = workspace:GetPartBoundsInRadius(v.Position,v.Size.Y,Params)
local okToMove = true
for i,v in ipairs(touchingParts) do
if v.CanCollide then
okToMove = false
end
end
if okToMove then
CustomVelocity += CustomGravity
v.CFrame += CustomVelocity
else
CustomVelocity = Vector3.zero
end
v:SetAttribute("ToldFable_Velocity",CustomVelocity)
--v:SetAttribute("ToldFable_Gravity",CustomGravity)
end
end
This is for a studio plugin, so I’ve written the code to be easily executable via the command bar
I’m trying to keep this physics as bare-bones/small as possible