TheWisest
|
  |
| Joined: 11 Nov 2010 |
| Total Posts: 7345 |
|
|
| 31 May 2014 02:38 PM |
In ray casting, say whenever someone walks in front of where the 'ray' is, it performs a event.
It seems pretty basic, but I can't seem to figure it out (I already know how to cast the ray itself, it is just this that I need help with) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 31 May 2014 02:39 PM |
The "FindPartOnRay" gives you the position and the part of what it hit.
|
|
|
| Report Abuse |
|
|
TheWisest
|
  |
| Joined: 11 Nov 2010 |
| Total Posts: 7345 |
|
|
| 31 May 2014 02:46 PM |
So could I do something like this?
par = script.Parent
Ray.new(par.Position, par.CFrame.lookVector * 500)
local hit, position = game.Workspace:FindPartOnRay(ray)
print(hit)
I already tried this and it didn't work and the output is giving me nothing.
|
|
|
| Report Abuse |
|
|
|
| 31 May 2014 02:47 PM |
You didn't define ray
ray = Ray.new(par.Position, par.CFrame.lookVector * 500) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 31 May 2014 02:50 PM |
Maybe it is not hitting anything, print position, hit
And also, define ray as island said |
|
|
| Report Abuse |
|
|
TheWisest
|
  |
| Joined: 11 Nov 2010 |
| Total Posts: 7345 |
|
|
| 31 May 2014 03:09 PM |
When a ray is created, how long does it last for?
Would I have to use a loop to continuously make a new ray, or once the ray is created, it is permanent until I say otherwise?
Thanks. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 31 May 2014 03:12 PM |
it doesn't "last" in any way All it does is give you a position (and whatever part it hit) based on the arguments.
Yes you would have to loop |
|
|
| Report Abuse |
|
|