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

Make raycasting ignore parts that have no collisions?

Asked by
gitrog 326 Moderation Voter
6 years ago
Edited 6 years ago

So, I have a raycasting gun script, and it works great. No problems. However, when the bullet would hit an invisible part with CanCollide off, it doesn't go through it. This is a problem, as this means players can not shoot through doorways, and most importantly, the areas designated for fighting are defined using a giant invisible part around the area.

How would I make it ignore parts with Transparency of 1 and CanCollide as false?

--Obviously just a segment of the script, no reason to post the 250 line+ script.
local NewPos =  mouse + Vector3.new(math.random(-spread,spread), math.random(-spread,spread), math.random(-spread, spread))
local ray = Ray.new(tool.firePart.CFrame.p, (NewPos - tool.firePart.CFrame.p).unit*300)
local part, position = game.Workspace:FindPartOnRay(ray, player.Character, false, true)
0
Just if you find an invisible part that cannot collide then make a new ray that has that object in the ignore list, I think that should work. hiimgoodpack 2009 — 6y
0
http://wiki.roblox.com/index.php?title=API:Class/Workspace/FindPartOnRayWithIgnoreList you will need to make a array of non collision parts User#5423 17 — 6y

Answer this question