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: Surface Touched?

Previous Thread :: Next Thread 
blockoo is not online. 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 is not online. 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 is not online. 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
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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
61352151511 is not online. 61352151511
Joined: 30 Nov 2009
Total Posts: 8094
01 Aug 2011 06:32 PM
Holy [ Content Deleted ]! AFF How the [ Content Deleted ] Did you come up with that!

‹•º`¨¨¨☺¨¨¨´º•¸
~ AeroMcCrash ~
~~~~ Mitch ~~~~
¸•º`¨¨¨☻¨¨¨´º•›
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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 is not online. 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 is not online. 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 is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
01 Aug 2011 06:59 PM
@AFF
Sometimes it prints false...
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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 is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
01 Aug 2011 07:26 PM
Now it ONLY prints false.
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