Shapecasting results in parts being overlapped

I have tried shapecasting a capsule onto a pyramid (both meshparts), and found out that the point from the result is not perfectly on surface but either inside or outside by a small distance. If you then apply cast direction * result.Distance, you end up with the part A penetrating the part B. At this moment, this issue halts the development of my game. I need this problem to be solved as soon as possible.

meshes i have tested with:
11643615120
7825007598
7280851812
15440301553
482906818

here’s simple code example:

local a: MeshPart = script.a
local b: MeshPart = script.b

game:GetService(“RunService”).Heartbeat:Connect(function(dt)
local dir = (b.Position - a.Position)
local result = workspace:Shapecast(a, dir)
local originCF = a.CFrame
if result then
a.CFrame = CFrame.new(originCF.Position + dir.Unit * result.Distance)
assert(#workspace:GetPartsInPart(a) == 0, “part is inside the other.”)
a.CFrame = originCF
end
end)

I would be glad to help you, but make sure first to click on the pen next to the title and change the category to #help-and-feedback:scripting-support. This will prevent your topic to get taken down.

1 Like

i have set the category of this very topic to #help-and-feedback:scripting-support so that you may now help me with this issue.

Oh, yea, sure then.

In the main topic, they talk about shapecast’s impact on performances. I think they probably made it less accurate to reduce the impact.

Otherwisely, what collision fidelity do you use (Hull, Box, etc…)? If it’s on PreciseConvexDecomposition, then the problem might be otherwhere.

Forcing it to be less accurate, without providing the developers with an option to toggle between accuracy and performance, is completely unprofessional. Ironic how the ROBLOX tech department aspires to extend the capabilities of their engine to attract production of sophisticated, higher-quality games, yet they routinely neglect common sense such as letting the DEVELOPER be in control of the performance of the game they are making.