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

findPartOnRay -- Why is it detecting itself? Do rays work in spheres?

Asked by 5 years ago
Edited 5 years ago

I have many sphere instances. They all shoot a ray and use findPartOnRay to see what's near them. The problem is that the ray start at the center of the sphere but can't make it out. It's like the sphere has thick skin.

https://i.imgur.com/LUOe1dd.jpg

If I use ignoreDescendantsInstance, the ray can pass through and hit other objects in the world as it should. But that solution isn't optimal because I have many spheres shooting rays all with different names.


--Sphere properties citizenID = citizenID + 1 local evo = Instance.new("Part", workspace) evo.Name = "citizen"..citizenID PhysicsService:SetPartCollisionGroup(evo, evoCollisionGroup) evo.CFrame = CFrame.new(9, 5, 5) evo.Shape = Enum.PartType.Ball evo.BrickColor = BrickColor.new("Bright green") evo.FormFactor = "Custom" evo.Material = "Neon" evo.Transparency = 0.25 evo.Anchored = true evo.Locked = false evo.CanCollide = true --Ray stuff local target = citizen.CFrame.p + Vector3.new(0, 15, 0) local ray = Ray.new(citizen.CFrame.p, (target - citizen.CFrame.p).unit * 50) local seen, hitposition = workspace:FindPartOnRay(ray, nil, false, true)

Also, if I change the part to a block instead of a sphere, and use the exact same code, everything works. Do rays not work in spheres or something?

Answer this question