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
 

Is it possible to get a surface of a Part with a Ray?

Previous Thread :: Next Thread 
ukwarrior6 is not online. ukwarrior6
Joined: 06 Sep 2009
Total Posts: 485
29 Oct 2013 08:17 PM
Is there any workarounds without using complex maths?
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
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
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
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
ukwarrior6 is not online. ukwarrior6
Joined: 06 Sep 2009
Total Posts: 485
29 Oct 2013 08:26 PM
Cheers for that, i'll have fun reading.
Report Abuse
woot3 is not online. 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 is not online. 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 is not online. stravant
Forum Moderator
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 is not online. YEGGOR
Joined: 02 Apr 2013
Total Posts: 1150
29 Oct 2013 11:58 PM
hello :P
Report Abuse
ukwarrior6 is not online. ukwarrior6
Joined: 06 Sep 2009
Total Posts: 485
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 is not online. 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
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