How to get Touched position?

Roblox Touched event doesnt properly show where a collision was made. Because of that, I can’t use effects on the right location for explosions and such. I do not want the position of the parts that touched, but the point where the collision was made. Trie raycasting but the results aren’t reliable sometimes, with the raycasting passing through and the physics colliding, or vice versa, due to acceleration and difference between steps. Did anybody have this problem and were able to solve it?

1 Like
local function onPartTouched(part)
    local ray = Ray.new(part.Position, part.Position - part.Velocity.Unit * 10)
    local hitPart, hitPosition = workspace:FindPartOnRay(ray)
 
    if hitPart then
        -- Use the hitPosition to apply effects or create explosions
        print("Collision point:", hitPosition)
    end
end

part.Touched:Connect(onPartTouched)

Try this.

1 Like

I did try this, but sometimes the ball already passed the collision position and isnt even facing the part it previously touched, making raycast not reliable. I tested making a .touched event after throwing the ball, which when triggered anchors the ball. The result was that sometimes it would stop right at the collision timing, sometimes before it touched and sometimes after it bounced, and so if the last result is the one that uses this raycast method, the ray would actually not point to the collision position. This problem isn’t just visible on most games because they usually destroy the instance afterwards.

1 Like

I also tried to update the ball last position and velocity, i use the ball last pos and raycast towards its velocity vector, but then comes the inconsistencies i told on the topic.

1 Like