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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|