Well, I’ve already created a topic about this but that brought a new problem so this is about that.
The small collision pins at the feet of Sonic have to be unanchored for them to detect collisions between parts but due to gravity, those parts fall faster than Sonic so they detect collisions too early.
Maybe positioning the parts to the bottom of the Sonic part will work, but I don’t know how to do that. Here’s the script “Main”.
local inAir = script.Parent.Variables.inAir.Value
local speedY = script.Parent.Variables.speedY.Value
local collisionBtmRight = script.Parent.Variables.collisionBtmRight.Value
local collisionBtmLeft = script.Parent.Variables.collisionBtmLeft.Value
wait(10)
--COLLISIONS
script.Parent.Parent.btmLeftAnchorPoint.Touched:Connect(function(part)
print("hi")
if part.BrickColor == BrickColor.new("Institutional white") then
collisionBtmLeft = true
end
end)
script.Parent.Parent.btmRightAnchorPoint.Touched:Connect(function(part)
print("bye")
if part.BrickColor == BrickColor.new("Institutional white") then
collisionBtmRight = true
end
end)
script.Parent.Parent.btmLeftAnchorPoint.TouchEnded:Connect(function()
collisionBtmLeft = false
end)
script.Parent.Parent.btmRightAnchorPoint.TouchEnded:Connect(function()
collisionBtmRight = false
end)
repeat
script.Parent.Parent.btmRightAnchorPoint.Anchored = false
script.Parent.Parent.btmLeftAnchorPoint.Anchored = false
--BASIC CHECKS
if collisionBtmLeft == false and collisionBtmRight == false then
inAir = 1
elseif collisionBtmLeft == true and collisionBtmRight == false then
inAir = 0.8
elseif collisionBtmLeft == false and collisionBtmRight == true then
inAir = 0.4
elseif collisionBtmLeft == true and collisionBtmRight == true then
inAir = 0
end
--GRAVITY
if inAir == 1 then
speedY = speedY - 0.1
else
speedY = 0
end
--MOVE PLAYER AND ANCHOR POINTS
script.Parent.CFrame = script.Parent.CFrame + Vector3.new(0, speedY, 0)
script.Parent.Parent.btmRightAnchorPoint.CFrame = script.Parent.Parent.btmRightAnchorPoint.CFrame + Vector3.new(0, speedY, 0)
script.Parent.Parent.btmLeftAnchorPoint.CFrame = script.Parent.Parent.btmLeftAnchorPoint.CFrame + Vector3.new(0, speedY, 0)
wait(0.01)
script.Parent.Parent.btmRightAnchorPoint.Anchored = true
script.Parent.Parent.btmLeftAnchorPoint.Anchored = true
until false