|
| 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
|
  |
| 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
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
| |
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 14 Aug 2015 03:06 PM |
Bump
Women are like fine wine, I can't get their tops off |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
| |
|
Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
|
| 14 Aug 2015 03:23 PM |
local ray=Ray.new(startPosition,endPosition)
|
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
|
| 14 Aug 2015 09:08 PM |
| This is a Discussion not a Argument. |
|
|
| Report Abuse |
|
|
| |
|
booing
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
| |
|