|
| 18 Jan 2015 07:58 PM |
Hey, so I was recently reading about raycasting on the roblox wiki and I don't really understand it. But I do know that it's a methode of detecting if any object is in the way of a part. Could someone explain some functions of raycasting? Thanks. |
|
|
| Report Abuse |
|
|
| |
|
cxcharlie
|
  |
| Joined: 26 Aug 2009 |
| Total Posts: 1414 |
|
|
| 18 Jan 2015 08:27 PM |
| Basically getting the object(s) hit within the ray and retrieving and accurate position of where they were hit on. For example it could be used for guns, detecting if a player is under a shelter, finding the distance from the ground, etc. |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2015 09:16 PM |
Nice, so I was working on reading the wiki, what do these functions do?:
Ray.new() FindPartOnRay() |
|
|
| Report Abuse |
|
|
Argelius
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 4047 |
|
|
| 18 Jan 2015 09:18 PM |
| Ray.new creates a ray, FindPartOnRay checks for parts intersecting the ray. |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2015 09:37 PM |
Ah ok! So here's an example script:
function raycast(start,finish,ignore) local offset=(start-finish).unit local ray=Ray.new(start,offset) local hit,pos=game.Workspace:FindPartOnRay(ray,ignore) if hit and pos then if hit.Transparency==1 then hit,pos = raycast(pos,offset,ignore) end end return hit,pos end
What does this script do? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
cxcharlie
|
  |
| Joined: 26 Aug 2009 |
| Total Posts: 1414 |
|
|
| 18 Jan 2015 11:55 PM |
It's basically the same thing as the raycast function except if it hits a transparent object it will raycast again and again until it actually his a non-transparent object
U wot m8 |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2015 01:32 AM |
| Oh! Nice. Ok thanks everyone! |
|
|
| Report Abuse |
|
|