Snowia
|
  |
| Joined: 15 Jan 2013 |
| Total Posts: 1753 |
|
|
| 11 Mar 2017 05:37 PM |
i know they have a page for that on the wiki, but i feel like it's been over complicated and i dont rly understand
i was hoping maybe someone could show me how to set up a simple raycast and explain it
|
|
|
| Report Abuse |
|
|
|
| 11 Mar 2017 05:41 PM |
| Click and the part will go where you click |
|
|
| Report Abuse |
|
|
|
| 11 Mar 2017 05:41 PM |
local Ray = Ray.new(startPosition,DirectionAndRange) -- local Ray = Ray.new(Vector3.new(0,0,0),Vector3.new(0,1,0)*100)
this will cast a ray starting from 0,0,0, moving upwards (1 on y axis is up) 100 studs (multiplying the direction by the range)
|
|
|
| Report Abuse |
|
|
Snowia
|
  |
| Joined: 15 Jan 2013 |
| Total Posts: 1753 |
|
|
| 11 Mar 2017 05:43 PM |
if i wanted to create a ray between part1 and part2
how would i calculate direction?
|
|
|
| Report Abuse |
|
|
|
| 11 Mar 2017 05:45 PM |
local direction = (part2.Position - part1.Position).unit
gets the difference between part2 and part1's position and turns it into a unit (which is the direction with a magnitude of 1, this can be found by dividing a vector by its magnitude: vector3/vector3.magnitude).
|
|
|
| Report Abuse |
|
|
Snowia
|
  |
| Joined: 15 Jan 2013 |
| Total Posts: 1753 |
|
|
| 11 Mar 2017 05:47 PM |
thanks
what do u mean by magnitude of 1?
|
|
|
| Report Abuse |
|
|
|
| 11 Mar 2017 06:10 PM |
the distance from a to b is 1 unit (the unit in this case is studs)
|
|
|
| Report Abuse |
|
|
Snowia
|
  |
| Joined: 15 Jan 2013 |
| Total Posts: 1753 |
|
| |
|