i’ve got a custom touch velocity function here:
local registered = {}
local newTouch = {}
local function getSize(v1:Vector3, v2:Vector3, psize:Vector3)
return
Vector3.new(
psize.X,
psize.Y,
math.abs(v1.Z-v2.Z)
)
end
newTouch.atVelocity = function(p:BasePart, func:(BasePart, RBXScriptConnection)->())
local olp = OverlapParams.new()
olp.FilterType = Enum.RaycastFilterType.Exclude
olp.FilterDescendantsInstances = {p}
local atRun : RBXScriptConnection
atRun = game["Run Service"].Heartbeat:Connect(function(dt)
if p.Parent == nil then atRun:Disconnect() end
local velocity = p.AssemblyLinearVelocity
local average = (p.Position + velocity * dt)/2
local cf = CFrame.lookAt(average, average + velocity)
local size = getSize(p.Position, p.Position + velocity * dt, p.Size)
local inbox = workspace:GetPartBoundsInBox(cf, size, olp)
for _, basepart in pairs(inbox) do
if basepart == p then return end
func(basepart, atRun)
end
end)
return
{
disconnect = function()
atRun:Disconnect()
end,
}
end
return newTouch
This is specifically for a cannonball, which is too fast for generic .Touch
to work, and is too big for raycasts
to detect most collisions, I do use raycasts alongside it but it is not suffiecent.
My custom function is still not detecting collisions, and I have no idea why.