Oh yeah! I could try to check on 4 sides
what if it’s overlapping the corner?
I will just make the sides on the insides?
Add 4 more on the 4 corners. It’s that simple
Though idk if that is the best thing to do. I am not an expert on luau
yeah, i guess that would work. just it might be laggy if youre checking a bunch of positions every moment.
Or i will try to figure something out with circle math??? I’ll see what i can do.
idk what you can do about the squares
What if i’d do:
local circle = --Path to circular object
local area = math.pow( circle.AbsoluteSize.X , 2) / 2 * math.pi
game:GetService("RunService").RenderStepped:Connect(function()
--Do something with the area???
end)
I dont know it’s worth making the “hitboxes” accurate to a circle because that would slow down the game considerably more than just having the hitboxes as squares.
Yeah… But that would kinda break the game’s purpose…
I’m currently checking this thing out called GuiCollisionService
im pretty sure i found a solution:
repeat wait() until game:IsLoaded() wait(.5)
local player = game.Players.LocalPlayer
local playerGui = player.PlayerGui
local frameA:Frame = playerGui.A.Frame -- assuming A is the screen gui name
local frameB:Frame = playerGui.B.Frame -- assuming B is the screen gui name
local function frame()
local positionA = frameA.AbsolutePosition
local positionB = frameB.AbsolutePosition
local sizeA = frameA.AbsoluteSize.X
local sizeB = frameB.AbsoluteSize.X
local size = math.max(sizeA,sizeB)
local distance = (positionA - positionB).Magnitude
if distance < size then
print("Overlapping")
end
end
game:GetService("RunService").Heartbeat:Connect(frame)
Oh i forgot to say, this will only work if anchor point is .5, .5 on both frames
Thank you! I will for sure try this!
YOOOO!!! THANK YOU SO MUCH, IT WORKED!! I REALLY APPRECIATE IT BRO!
This detects a touch of even a pixel. @InfinityGamingRBLX if you want something like agar.io, you want to check if the bigger circle is completely overlapping the smaller one.
Yeah i want it to happen even though a pixel is getting overlapped. Thanks for asking though!
okay, so i was playing around with the script for a while and realized there was a problem
when the frames are sized differently and the bigger one is on the right of the smaller one. here is the new script:
repeat wait() until game:IsLoaded() wait(.5)
local player = game.Players.LocalPlayer
local playerGui = player.PlayerGui
local frameA:Frame = playerGui.A.Frame -- assuming A is the screen gui name
local frameB:Frame = playerGui.B.Frame -- assuming B is the screen gui name
local function frame()
local sizeA = frameA.AbsoluteSize.X
local sizeB = frameB.AbsoluteSize.X
local size = math.max(sizeA,sizeB)
local min = math.min(sizeA,sizeB)
local positionA = frameA.AbsolutePosition
local positionB = frameB.AbsolutePosition
if sizeA > sizeB then
positionA += Vector2.new(math.abs(sizeA - sizeB) / 2,math.abs(sizeA - sizeB) / 2)
else
positionB += Vector2.new(math.abs(sizeA - sizeB) / 2,math.abs(sizeA - sizeB) / 2)
end
local distance = (positionA - positionB).Magnitude
if distance < size - (size - min) / 2 then
print("Overlapping")
end
end
game:GetService("RunService").Heartbeat:Connect(frame)
when i tried this, it worked. hopefully this script has no problems.
Oh okay! No problem! Thanks again!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.