I need help with raycasting

I am very confused on how the directional element of raycasts work. I have created an anti-noclip script with raycasts in the HumanoidRootPart that rubberbands the player if they are in a wall. It works phenomenally at preventing noclipping, but the issue is walking up against a wall causes rubberbanding. How should I be casting these rays?

I am currently casting using



1 Like

the rayDirection is the direction the ray is casted with the length being the number input on the axis it’s casting to (in your case it will be 1) in studs, think of it as poking a 1 stud long part around your character. the problem you’re encountering is that your raycast is touching the wall while the player is not inside it due to the ray being too long, you can try changing the length and see which works best while still keeping it functional

What Vector3 value would you suggest? I’ve been messing with the numbers for around 3 days, and still can’t figure this out.

1 Like

I don’t believe it’d be possible to get it to the perfect length that keeps it functional and short enough to not reach walls while not inside them, this approach would only be able to minimize the effect, I’d recommend trying different methods of preventing noclips if this compromise isn’t ideal

I fixed my issue 100%! It still works phenomenally, and I haven’t gotten a single false-positive! These are the rays:

1 Like