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 » Scripting Helpers
Home Search
 

Re: raycast detect face and surface gui position detection?

Previous Thread :: Next Thread 
doneyes is not online. doneyes
Joined: 21 Mar 2008
Total Posts: 3466
14 Jan 2014 03:49 PM
I want to cast a ray at a wall, place a surface gui on that wall, and then place a image on the surface gui at the point that the ray hit. How?
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
14 Jan 2014 04:02 PM
Meh, I'll post it:


What you do is this:



FindPartOnRay and such returns two values:

Part that got touched and the position it touched at.



What to do:
If there is a part, then
Convert the returned position to a CFrame:

CFrame.new(WherePartGotTouched)

Then you get the part and do this:

local pos = PartThatGotTouched:toObjectSpace(CFrame.new(WherePartGotTouched))
local X1,Y1,Z1 = pos.X,pos.Y,pos.Z
local X2,Y2,Z2 = PartThatGotTouched.X,PartThatGotTouched.Y,PartThatGotTouched.Z

local X,Y,Z = X1-X2,Y1-Y2,Z1-Z2

I think you can figure out the rest from there.
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
14 Jan 2014 04:04 PM
Noticed some errors:

local pos = PartThatGotTouched.CFrame:toObjectSpace(CFrame.new(WherePartGotTouched))
local X1,Y1,Z1 = pos.X,pos.Y,pos.Z
local X2,Y2,Z2 = PartThatGotTouched.CFrame.X,PartThatGotTouched.CFrame.Y,PartThatGotTouched.CFrame.Z

local X,Y,Z = X1-X2,Y1-Y2,Z1-Z2
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
14 Jan 2014 04:08 PM
-- Noticed an idiotic flaw. Shouldn't repurpose my GUI collision script.


local pos = PartThatGotTouched.CFrame:toObjectSpace(CFrame.new(WherePartGotTouched))
local X,Y,Z = pos.X,pos.Y,pos.Z




then you would detect the side using if X > 0 and such.



Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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