Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make a raycast function that ignores non-cancollided parts?

Asked by 7 years ago

I want to make a raycast function that allows you to shoot a ray through bricks that have cancollide turned off. I've tried adding the bricks to the Ignorelist and the mouse TargetFilter, and in both cases, the ray is not accurate, does not fire at the spot that the mouse is pointing to, and ends up being at an offset angle. Help?

0
Adding the bricks to the ignorelist would work, it's not accurate because the mouse is focused on the non-collided part. Shadowthaumaturge 97 — 7y
0
How would I make the mouse ignore the non-collided part? I already tried putting it on the TargetFilter. ShadowsDev 62 — 7y
0
heres what i would try, i would raycast from the camera to the mouse that continues on, having the parts with cancollide off in that ray's ignorelist too fanofpixels 718 — 5y

1 answer

Log in to vote
0
Answered by
angeI1001 123
5 years ago

Here's an example of how you can do this:

local ray = Ray.new(player.Lightning.WorldPosition.WorldPosition,player.HumanoidRootPart.CFrame.lookVector.unit*100)
local ignore = workspace.Noncollide:GetChildren();
table.insert(ignore,player)
local Part,Position = game.Workspace:FindPartOnRayWithIgnoreList(ray,ignore)

I hope this helped you.

Ad

Answer this question