blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 01 Aug 2011 06:08 PM |
| Is there a way to index what surface was touched in a Touched event? |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 01 Aug 2011 06:11 PM |
Only this ways :P
Otherwise i don't think that is possible.
function onTouched(hit) if script.Parent.TopSurface = "Smooth" then print("Its Smooth Brick") end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 01 Aug 2011 06:12 PM |
| That doesn't really tell me which, though. I suppose I could CFrame some invisible bricks into the sides and do it that way. |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2011 06:30 PM |
function getSideTouched(myPart, collidingPart) local SIZE = myPart.Size local S = collidingPart.Size local O_o = myPart.CFrame:pointToObjectSpace(collidingPart.Position) return O_o.y >= SIZE.y/2+S.y/2 and "Top" or O_o.y <= SIZE.y/2-S.y/2 and "Bottom" or O_o.x >= SIZE.x/2+S.x/2 and "Right" or O_o.x <= SIZE.x/2-S.x/2 and "Left" or O_o.z >= SIZE.z/2+S.z/2 and "Front" or O_o.z <= SIZE.z/2-S.z/2 and "Back" end
function Touched(hit) print( getSideTouched(script.Parent, hit) ) end script.Parent.Touched:connect(Touched)
Try that. :O |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2011 06:32 PM |
Holy [ Content Deleted ]! AFF How the [ Content Deleted ] Did you come up with that!
‹•º`¨¨¨☺¨¨¨´º•¸ ~ AeroMcCrash ~ ~~~~ Mitch ~~~~ ¸•º`¨¨¨☻¨¨¨´º•› |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2011 06:39 PM |
New script:
function getSideTouched(myPart, collidingPart) local SIZE = myPart.Size local S = collidingPart.Size local O_o = myPart.CFrame:pointToObjectSpace(collidingPart.Position) return O_o.y >= SIZE.y/2+S.y/2 and "Top" or O_o.y <= -SIZE.y/2-S.y/2 and "Bottom" or O_o.x >= SIZE.x/2+S.x/2 and "Left" or O_o.x <= -SIZE.x/2-S.x/2 and "Right" or O_o.z >= SIZE.z/2+S.z/2 and "Back" or O_o.z <= -SIZE.z/2-S.z/2 and "Front" end
function Touched(hit) print( getSideTouched(script.Parent, hit) ) end script.Parent.Touched:connect(Touched)
Basic math and logic about 3D environments. :P If something is touching something else, only one of these conditions are possible. A part can't touch both the top/bottom surface at the same time as one of the side surfaces. Said brick wouldn't touch at all. |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 01 Aug 2011 06:47 PM |
| Ok, thanks. I already CFramed bricks into each side but if this works better I'll use it instead. |
|
|
| Report Abuse |
|
|
Ulla42
|
  |
| Joined: 14 Dec 2009 |
| Total Posts: 1774 |
|
|
| 01 Aug 2011 06:57 PM |
| If no luck, Zipperipper did something like that using raycasting. You can check it out in his models. |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 01 Aug 2011 06:59 PM |
@AFF Sometimes it prints false... |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2011 07:22 PM |
The slight delay may be breaking it... Try this:
function getSideTouched(myPart, collidingPart) local SIZE = myPart.Size local S = collidingPart.Size local O_o = myPart.CFrame:pointToObjectSpace(collidingPart.Position) return O_o.y >= SIZE.y/2+S.y and "Top" or O_o.y <= -SIZE.y/2-S.y and "Bottom" or O_o.x >= SIZE.x/2+S.x and "Left" or O_o.x <= -SIZE.x/2-S.x and "Right" or O_o.z >= SIZE.z/2+S.z and "Back" or O_o.z <= -SIZE.z/2-S.z and "Front" end
function Touched(hit) print( getSideTouched(script.Parent, hit) ) end script.Parent.Touched:connect(Touched) |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
| |
|