Roblox's Shape casting methods weirdly unprecise

Recently, I’ve been working on a project that depends a lot on shape casting using Roblox’s built-in methods, and honestly, all of them are so imprecise that it’s been really frustrating. It’s just meant to be a movement system, but there are so many annoying issues because methods like Shapecast and Spherecast are just not reliable. Both Spherecast and Shapecast can go right through seams in parts, which makes no sense at all.

So, I’m wondering. Why are all the casting methods this imprecise?

edit: This was originally in the #development-discussion section.

1 Like

Sounds like a bug, unless your shapecasts are really small. You can try using a tool like CastVisuals to make sure there isn’t a problem with your code. You can also contribute to this Bug Report, if it seems to be describing your problem:

Nope, they are quite large. I’ve used my dumpcast library for visualizing raycasts & while walking against walls with seams, it just randomly goes through the seams and causes me to walk INSIDE the seam.

I mean, it IS a bug. But it mostly looks like a precision issue with the casting implementation itself.

Looking at other character controller implementations, like chickynoid. They use their own collision system by constructing hulls of meshes and parts. They do not have these precision issues. It actually looks like an issue with Roblox’s casting implementations being too imprecise. We cant really do nothing about it unless we get it on the roadmap or something.

Damn, that sucks. Did you want to try coding a shapecasting engine yourself then? Surely yours would be more precise?

The Roadmap is for high-level features, not for bugs. The But Report I linked was created during the engineer’s holidays, I think they’ll all be back in office soon (and some of them already seem to be, given they’ve been responding and investigating other big reports).

I’d like to say that in that bug report, he implemented the skin incorrectly, and that’s why it isn’t functioning as it should for him. I have had success with using shape casts for collision detection; the issue is less with precision and more with the lack of margins, at least in my case.

They’re not. You are just using them wrong clearly. Raycasts are very accurate hence the libraries and systems built around the very thing you curse.

I would gladly attempt to do so, but i guess i dont have enough knowledge. I barely understand what chickynoid has laid down, however i could try. The main reason why i didnt opt to go with my own shapecasting engine is mostly because of model fidelity. I’ve only seen implementations of Hull algorithms, which arent really precise enough. I’ll sure study up & figure out atleast generating approximate convex decompositions of models & such.

Im not talking about raycasts. Shapecasts are mostly the issue. Sure, they’re precise enough for most tasks, however they’re still not as precise as i’d like them to be. Please do not accuse me of using something wrong, when its just a shapecast. Shapecasts are NOT supposed to phase through minuscule gaps that arent even visible.

Do you have a reproduction file for clipping through seams? I have gotten shape casts working pretty well without any clipping.

Sure, ill make one. I’m not quite comfortable with sharing my movement system code, so ill attempt to reproduce it.

I know that. But if your doing physics stuff and not optimising your physics well then you will have to expect clipping. Also shape casts and raycasts are the same thing just different hit boxes really. So either one I talk off it will all be the same ofc unless x.

Some precision issues have been reported in the past, but I am not sure if they have been fixed, as nothing was ever said in the reports after staff acknowledged them.

You cant expect help without sharing also I recommend moving it to #help-and-feedback:scripting-support

I am sure most of them if not all are done by now. if not they’re still fairly accurate either way so it shouldnt be an issue.

How does optimizing physics have anything to do with clipping? What are you even talking about? Also, shape casts, and ray casts are conceptually similar but very different implementation-wise.

Right, ill do so right now. character limit

You don’t have to reply each time by the way in these cases its more of a just do and forget. just saying.

Alright, while attempting to reproduce the issue i have successfully figured out why it was clipping through seams.

While pushing against a wall, my character may have clipped inbetween both of the parts in the center of the seam (an incorrect skin implementation, it looks like). Which means the shapecast origin is inside of the 2 walls where the seam is. In Roblox’s implementation, this causes it to whitelist any parts which are already clipped into the origin.

Thanks, to all who helped. I’ll attempt to fix my skin implementation later when im done rewriting my movement system a bit.