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: Could someone explain basic raycasting to me

Previous Thread :: Next Thread 
Snowia is not online. 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
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
11 Mar 2017 05:41 PM
Click and the part will go where you click
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
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 is not online. 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
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
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 is not online. 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
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
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 is not online. Snowia
Joined: 15 Jan 2013
Total Posts: 1753
11 Mar 2017 06:28 PM
ok thanks


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