Raycast intersects with nothing/doesn't detect thin parts

Hello!

I’ve been fiddling with raycasting and it doesn’t behave as expected


a demo of the problem

As shown in the video, raycasts act weirdly when you’re angled nearly parallel to the angle of the face of the part, and on the edges of the face (not the topological edges), detecting an intersection where it shouldn’t be.
What’s more is that they don’t even detect intersections with the part if the face you’re facing is thin (shown in the video as well)

also if you’re close enough to the part, you can make areas near the edges detect, this is the closest i managed to get it (the red line is a ray)

image

and the rays dont reach the wall, in some cases when you update the rays too frequently they actually overshoot past the wall’s boundaries and go through them
image

On the forum I haven’t been able to find a solution for this exact problem, only some specific case when the ray is intersecting the part directly on the topological edge

Perhaps the problem is in my script, it casts a ray originating from the player’s head and ending at 100 studs infront of it, with some offset to the left/right, depending on the variable i

demo:

raysrc.ray() is a function from a module i made to simplify visualizing raycasts, i dont think it has anything to do with this problem, also note that the distance is how much studs away will the raycast’s end goal be at

Is this problem involved with the script or with roblox’s raycasting?

Try removing head.Position from your direction vector, direction vectors should be not be confused with position vectors.

1 Like

You’re right, but this doesn’t work, I’ve added head.Position because without it the effect was even worse for some reason.

I’m curious what does your direction print?

1 Like

Say, the player spawns with all orientation set to 0 degrees.

The X component of the direction would go from -5 to 5, Z would stay 100

At an angle of 45 degrees, the X component would go from -73 to -66, and the Z component would be the reverse of that (approximately)

I don’t think that direction is the problem here. I’ve tried sending a single ray strictly in-front of the player, but it’d still get “distorted”

Then perhaps the visualization is wrong?

I’ve seen that happen before on the devforum which is why I recommend putting in the code.

1 Like

It wasn’t

It turns out that I have residue junk in my module, that was the actual cause.

Actually pretty weird that I blamed studio for that and didn’t think of looking through my module. Thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.