generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Raycasting ray to go straight forward?

Previous Thread :: Next Thread 
LordxLoss is not online. 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 is not online. LordxLoss
Joined: 02 Jun 2012
Total Posts: 1999
17 Oct 2015 12:58 PM
bump
Report Abuse
benthanh123 is not online. benthanh123
Joined: 27 May 2010
Total Posts: 567
17 Oct 2015 01:27 PM
CFrame.lookVector
Report Abuse
LordxLoss is not online. 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 is not online. 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 is not online. 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 is not online. LordxLoss
Joined: 02 Jun 2012
Total Posts: 1999
17 Oct 2015 11:20 PM
bump
Report Abuse
LordxLoss is not online. LordxLoss
Joined: 02 Jun 2012
Total Posts: 1999
17 Oct 2015 11:40 PM
Oh, it works now.
Thanks!
Report Abuse
FlyNormal is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image