Hey there, Fusioncore21 back at it again!
Alright, so recently I have been looking at Rays for a game prototype I have been working on.
Now, the idea is that I have a laser and a mirror. The laser sends out a ray towards anything in front of it. I already have the ray emitting thing working, but all I am coming to you for is to figure out how to find the distance of how far the ray had to travel before hitting the part I want. I looked on the API but it does a really bad job of explaining it for me.
Here is my code which is really badly formatted, sorry.
local whitelist = workspace.GameEnvironment.Game1.ImportantStuff:GetChildren()
local Ignore = workspace.AlphaLaser
wait(0.5)
local Col = Ray.new(workspace.AlphaLaser.Emitter.Position,workspace.AlphaLaser.Emitter.CFrame.RightVector.Unit*100)
Collison = workspace:FindPartOnRayWithWhitelist(Col,whitelist)
--Point = Col:Distance(Col:ClosestPoint()) -- This didn't work when I tried it
print(Collison.Parent)
Any help would be appreciated.
Thanks.