LordxLoss
|
  |
| Joined: 02 Jun 2012 |
| Total Posts: 1999 |
|
|
| 17 Oct 2015 12:51 PM |
Just started raycasting, and Im finding it hard to learn from the wiki on this particular subject (Please dont link to me to the wiki.) Im learning from gun scripts, but Im working on a gun laser that should raycast a ray to go straight forward. (Not working on a laser gun, laser= laser sights thing like in CoD.)
This is the current ray script, Ik it points toward the mouse (which is glitch af btw,) but I have no idea on how to make it point forward regardless of where the tool is pointing.
ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p))
Help? |
|
|
| Report Abuse |
|
|
LordxLoss
|
  |
| Joined: 02 Jun 2012 |
| Total Posts: 1999 |
|
| |
|
| |
|
LordxLoss
|
  |
| Joined: 02 Jun 2012 |
| Total Posts: 1999 |
|
|
| 17 Oct 2015 02:10 PM |
It works, kind of, but the ray is extremely short. How do I make it longer? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 17 Oct 2015 02:52 PM |
| Multiply the lookVector by how many studs you want it to go. |
|
|
| Report Abuse |
|
|
LordxLoss
|
  |
| Joined: 02 Jun 2012 |
| Total Posts: 1999 |
|
|
| 17 Oct 2015 02:59 PM |
Didnt work, assuming you meant
Handle.CFrame.lookVector*300 |
|
|
| Report Abuse |
|
|
LordxLoss
|
  |
| Joined: 02 Jun 2012 |
| Total Posts: 1999 |
|
| |
|
LordxLoss
|
  |
| Joined: 02 Jun 2012 |
| Total Posts: 1999 |
|
| |
|
FlyNormal
|
  |
| Joined: 30 Sep 2015 |
| Total Posts: 344 |
|
|
| 17 Oct 2015 11:52 PM |
| Yea lookVector returns a unit vector of the part's view direction. A unit vector is a vector with magnitude 1 and but the direction stowed. To increase the magnitude of the vector, just time the unit vector by the magnitude you aim for. |
|
|
| Report Abuse |
|
|