Raycast not detecting if there are parts ON TOP of another part (with drawings for extra clarification)

Managed to solve it, I had to use an actual part and use that as reference. Works perfectly now, just gotta polish everything up.

I seriously appreciate the help everyone, yall gave me some really good insight and alternative solutions.

I’m still not entirely sure why Raycasting was behaving so weirdly without a physical reference, but I’m assuming it’s because .LookVector and .UpVector don’t hold any actual meaning when you try to apply it to a position in the world.

No your math is all wrong, and makes no sense. Your visualization is not showing u where the ray is actually going because:

local NewRaycastDirection = CFrame.lookAt(NewRaycastOrigin.Position, DeltaPosition)

CFrame.lookAt, returns a CFrame. You get the direction by asking that CFrames .LookVector (A direction with the length of 1 stud), a Vector3

You were supposed to be calculating a Point in absolute (World) space; then Looking at that Point from the absolute Position of the Torso or somewhere: Get the Unit Vector (Angle), with .LookVector; then multiplying that by a Number to get a longer Ray.

You never multiply it; thus it should show a Ray with a length of one.

This code is not going to work.I have no idea how you derive at your Origin. Plus you are using the old Ray method.

I can’t help you.

But you should at least use the DrawRay function, I gave you. It is tested. It shows the Ray which you are actually shooting.

And it uses the new RayCast.

GL

1 Like

I see, thanks for the advice. I’m not too good with manipulating CFrames so I found this a pretty good lesson.