BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
|
| 28 Nov 2013 02:22 PM |
The Engine(Script 1):
_G["Collision"] = function(first,second)
if first:IsA("GuiBase") and first.Name == "EnemyBot" then end if second:IsA("GuiBase")and second.Name == "bullet" then end if (first.AbsoluteSize.X ~= first.AbsoluteSize.Y) then error("Bad argument #2 at first input; invalid size: X and Y dont match, cant calculate collision if Size.X and Size.Y are not the same",0) end if (second.AbsoluteSize.X ~= second.AbsoluteSize.Y) then error("Bad argument #2 at second input; invalid size: X and Y dont match, cant calculate collision if Size.X and Size.Y are not the same",0) end
local collision = false
if (((((first.AbsolutePosition.X+(first.AbsoluteSize.X/2))-(second.AbsolutePosition.X+(second.AbsoluteSize.X/2)))^2) + (((first.AbsolutePosition.Y+(first.AbsoluteSize.X/2))-(second.AbsolutePosition.Y+(second.AbsoluteSize.X/2)))^2)^0.5) <= ((first.AbsoluteSize.X/2) + (second.AbsoluteSize.X/2))) then collision = true end print(collision) return collision end
The Collision Checker(Script 2):
while true do wait(.01) a = script.Parent:WaitForChild("EnemyBot") b = script.Parent:WaitForChild("bullet") if Collision(a,b) then print("They Collided!") end end
No output |
|
|
| Report Abuse |
|
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
| |
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
| |
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
| |