|
| 17 Jul 2014 03:18 PM |
| I looked at the wiki article, but I didnt really undertand what to use and what not to use, because of the whole rectangle thing. I was hoping someone, if they didnt mind, could dumb it down for me. |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 17 Jul 2014 03:22 PM |
Ok, since roblox didnt come up with a touched function, we have to make it ourselves.
local function Collide(gui1,gui2) return ((gui1.Position.x < gui2.Position.x+gui2.Size.x and gui1.Position.x+gui1.Size.x > gui2.Position.x) and (gui1.Position.y > gui2.Position.y and gui1.Position.y < gui2.Position.y+gui2.Size.y)) or ((gui2.Position.x < gui1.Position.x+gui1.Size.x and gui2.Position.x + gui2.Size.x >gui1.Position.x) and (gui2.Position.y > gui1.Position.y and gui2.Position.y < gui1.Position.y+gui1.Size.y)) end
See this Code.
So lets start
It checks for the position of gui one, the top left. But sometimes things collide from the right, right? so we need to check that. The way is adding the x size. For getting the bottom, you add the y size.
so, with it checking all of the sides, if gui2 is more than it, in all ways, it will check for being collided from the middle and onwards.
Hope this helps! |
|
|
| Report Abuse |
|
|
|
| 17 Jul 2014 03:24 PM |
Wiki usually never helps with stuff.
If you need help just ask Kev lol. |
|
|
| Report Abuse |
|
|
|
| 17 Jul 2014 03:28 PM |
| thanks im going to try that right now |
|
|
| Report Abuse |
|
|
|
| 17 Jul 2014 03:37 PM |
wait, but what if the gui you want to know is touching something doesnt have anything there to touch it yet
im trying to make a GUI dartboard that only counts bullseyes, and i have everything done but the part where it checks if the dart touches the bullseye. the script creates a 5 by 5 gui frame, and puts it on the board. the thing it needs to hit is 30 by 30. what would i have to put into the 30 by 30 piece to check, say every 1 second, if a gui named "dart" appeared inside of it. |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 17 Jul 2014 05:32 PM |
I dont really understand what your saying, but, if you mean the bullets are being created, then maybe do something like this? :P
while wait() do for i,v in pairs(WHERETHEBULLETSARECREATED:GetChildren()) do if Collide(v, thetarget) then print'colliding!' end end end
|
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
| |
|