|
| 29 Oct 2013 08:17 PM |
| Is there any workarounds without using complex maths? |
|
|
| Report Abuse |
|
|
|
| 29 Oct 2013 08:22 PM |
A brief search on the good ol' google says: http://www.roblox.com/Forum/ShowPost.aspx?PostID=80373978
~The alpaca of the acting world. |
|
|
| Report Abuse |
|
|
|
| 29 Oct 2013 08:25 PM |
Oh and the workaround you're looking for could be found on the thread linked in that thread
http://www.roblox.com/Forum/ShowPost.aspx?PostID=52742200
~The alpaca of the acting world. |
|
|
| Report Abuse |
|
|
|
| 29 Oct 2013 08:26 PM |
| Cheers for that, i'll have fun reading. |
|
|
| Report Abuse |
|
|
woot3
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 3599 |
|
|
| 29 Oct 2013 09:11 PM |
Why do people always think it's so complicated. Naturally, it's simple. You need only calculate which surface the ray is closest to. |
|
|
| Report Abuse |
|
|
jewelycat
|
  |
| Joined: 10 Sep 2008 |
| Total Posts: 17345 |
|
|
| 29 Oct 2013 09:20 PM |
^ Comparing actual distances of the surfaces is inefficient.
Also, cool, old thread of me was posted.
Also also, if you want clean, optimized code for doing this, here it is:
pos = Ray hit position p = Ray hit object
local vec = p.CFrame:pointToObjectSpace(pos) local s = p.Size / 2 if (math.abs(vec.x - s.x) < 0.1) then return "Right" end if (math.abs(vec.x + s.x) < 0.1) then return "Left" end if (math.abs(vec.y + s.y) < 0.1) then return "Bottom" end if (math.abs(vec.y - s.y) < 0.1) then return "Top" end if (math.abs(vec.z - s.z) < 0.1) then return "Back" end if (math.abs(vec.z + s.z) < 0.1) then return "Front" end |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 29 Oct 2013 10:09 PM |
The most complete packaged up implementation of it, which works on all part and terrain shapes, is the one that I've developed for a few things. You can find a copy of it in here:
http://wiki.roblox.com/index.php/User:XLEGOx/newdragger
The relevant function is "GetGeometry", which takes a hit position and a hit part, and returns a data table describing the face that was hit by giving it's normal, vertices and edges. Returns only a normal if the hit object is a sphere.
It works for all of the crazy part types such as corner wedges, and works for all terrain shapes as well. |
|
|
| Report Abuse |
|
|
YEGGOR
|
  |
| Joined: 02 Apr 2013 |
| Total Posts: 1150 |
|
| |
|
|
| 30 Oct 2013 10:01 AM |
Awesome, didn't think this would get so much attention, I was hoping if there was anything in the Ray objects that allowed you to work it out without doing all the maths, but you've shown me that all the maths has been done for me :D
Thanks y'all, expecially you YEGGOR, your input was invaluable. |
|
|
| Report Abuse |
|
|
YEGGOR
|
  |
| Joined: 02 Apr 2013 |
| Total Posts: 1150 |
|
|
| 30 Oct 2013 05:59 PM |
you spelled controversial wrong.
also i was just testing my web browser xD |
|
|
| Report Abuse |
|
|