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: Any one kind enough to explain raycasting?

Previous Thread :: Next Thread 
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
14 Aug 2015 01:29 PM
So, I followed the roblox wiki, and I'm still non the wiser on how to create rays?
Could anyone make a script that maybe prints the distance of a part from another part and show me how it works?

Thanks

Women are like fine wine, I can't get their tops off
Report Abuse
Drakles is not online. Drakles
Joined: 19 Oct 2014
Total Posts: 1066
14 Aug 2015 01:30 PM
To find the distance from one part to another? You could use magnitude for that.

print((one.Position - two.Position).magnitude)

Life is short, so grip it and rip it.
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
14 Aug 2015 01:30 PM
raykasting
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
14 Aug 2015 01:31 PM
Oh, gg.
Well, please could you explain it to me? I'm not use to this part of Lua.I prefer GUIs, but I want to learn more.

Women are like fine wine, I can't get their tops off
Report Abuse
Drakles is not online. Drakles
Joined: 19 Oct 2014
Total Posts: 1066
14 Aug 2015 01:32 PM
Using magnitude is simple.

(startingPosition - endingPosition).magnitude

Result: the distance between them.

Life is short, so grip it and rip it.
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
14 Aug 2015 01:37 PM
I don't actually need to find the distance between two parts, I just used it as an example, but thanks anyway!

Women are like fine wine, I can't get their tops off
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
14 Aug 2015 03:06 PM
Bump

Women are like fine wine, I can't get their tops off
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
14 Aug 2015 03:15 PM
Nah Your idiot's Thats the distance between the center's He obviously wants nearest corner/side.
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
14 Aug 2015 03:18 PM
omfg. No I don't want distance, but thanks anyway. I just wanted that as an example. Could someone explain raycasting please?
Women are like fine wine, I can't get their tops off
Report Abuse
IllegallyBlind is not online. IllegallyBlind
Joined: 07 Nov 2010
Total Posts: 1691
14 Aug 2015 03:20 PM
I can EXPLAIN what raycasting itself is.

Raycasting is really sending an imaginary projectile from one position to another. It returns the first object it hits, if any, and the position it hit it at. You can ignore certain objects with the :FindPartOnRay ignorelist.


Check out my in-game scripting tutorial! [ 279086510 ]
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
14 Aug 2015 03:22 PM
PS If u want the distance betwenen balls you could do

(p1.Position - p2.Position).magnitude - (p2.Position-p1.Position).unit * (p1.Size.X + p2.Size.X)
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
14 Aug 2015 03:22 PM
Oops /2 The size X's.
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
14 Aug 2015 03:23 PM
local ray=Ray.new(startPosition,endPosition)
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
14 Aug 2015 03:29 PM
think of rays like how they are in math. theoretically, a ray is a half-line that begins at a specified point, and goes off into a direction forever.

well, with roblox, we are limited to rays with a length of 999 studs (but you could use segmented raycasting to bypass this)

so, Ray.new takes 2 arguments. the first argument is a vector3, and that vector3 is where the ray begins. the second argument is a vector3 direction, a unit vector.

a common exmaple is to use raycasting to cast a ray in mouse direction, from a weapon's handle.

local desiredDistance = 200 -- in studs

local ray = Ray.new(yourTool.Handle.Position,
(mouse.Hit.p - yourTool.Handle.Position).unit * desiredDistance)

what is it you don't understand?
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
14 Aug 2015 03:32 PM
I got it now. You cleared it up, thanks. I was unsure of the arguments.

Women are like fine wine, I can't get their tops off
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
14 Aug 2015 09:08 PM
This is a Discussion not a Argument.
Report Abuse
DeathsLASTwords is not online. DeathsLASTwords
Joined: 28 Jan 2012
Total Posts: 2701
14 Aug 2015 09:31 PM
reported booing
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
15 Aug 2015 02:07 AM
Shut it kid
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