#Rotation makes Gui Overlap not work

1 messages · Page 1 of 1 (latest)

obsidian grotto
#

local button = script.Parent
local FakeArrow = script.Parent.Parent.Arrow
local RealArrow = script.Parent.Parent.Arrow.Arrow
local HitMarker = script.Parent.Parent.HitMarker
local RunService = game:GetService("RunService")

local rotationSpeed = 200 -- degrees per second

function isOverlap(HitMarker, RealArrow)
local HitMarkerPos = HitMarker.AbsolutePosition
local HitMarkerSize = HitMarker.AbsoluteSize
local RealArrow2Pos = RealArrow.AbsolutePosition
local RealArrowSize = RealArrow.AbsoluteSize

return HitMarkerPos.X < RealArrow2Pos.X + RealArrowSize.X and
    HitMarkerPos.X + HitMarkerSize.X > RealArrow2Pos.X and
    HitMarkerPos.Y < RealArrow2Pos.Y + RealArrowSize.Y and
    HitMarkerPos.Y + HitMarkerSize.Y > RealArrow2Pos.Y

end

RunService.RenderStepped:Connect(function(dt)
FakeArrow.Rotation = (FakeArrow.Rotation + rotationSpeed * dt) % 360
end)

button.MouseButton1Click:Connect(function()

if isOverlap(HitMarker, FakeArrow) then
    print("yes")
else
    print("nope")
end

end)

#

So the problem is that I am trying to make a dbd skill check but the problem is that this won't work because absolute value would not change because of rotation

#

it only looks visually correctly

upbeat tulip
#

Can you send a visual repr of the bug?

obsidian grotto
obsidian grotto
#

Because rotation does change the absoulte postion of the arrow

upbeat tulip
#

Whatr u trying to make

obsidian grotto
#

dbd skill check

#

The middle is the part that rotates and the arrow is under it

upbeat tulip
#

Expand dbd

obsidian grotto
#

So it circles around and you have to click the button when it lines up with the square

upbeat tulip
#

I see

#

If the parent will rotate, the child will as well

#

dont parent arrow ui to the circle thing

untold bobcatBOT
#

studio** You are now Level 6! **studio

obsidian grotto
#

But I want it to rotate with it

#

Bascially I want it to detect the overlaping but it does not because it does not update with the rotation

#

So it would be logically not moving even if it looks like it is

obsidian grotto
upbeat tulip
#

How r u determining if the position of the arrow lies in the threshold when the space key is hit?

obsidian grotto
upbeat tulip
#

what? like how?

obsidian grotto
#

The script

upbeat tulip
#

yea but how

obsidian grotto
#

just press the button and it checks the overlay

upbeat tulip
#

using orientation?

obsidian grotto
#

function isOverlap(HitMarker, RealArrow)
local HitMarkerPos = HitMarker.AbsolutePosition
local HitMarkerSize = HitMarker.AbsoluteSize
local RealArrow2Pos = RealArrow.AbsolutePosition
local RealArrowSize = RealArrow.AbsoluteSize

return HitMarkerPos.X < RealArrow2Pos.X + RealArrowSize.X and
    HitMarkerPos.X + HitMarkerSize.X > RealArrow2Pos.X and
    HitMarkerPos.Y < RealArrow2Pos.Y + RealArrowSize.Y and
    HitMarkerPos.Y + HitMarkerSize.Y > RealArrow2Pos.Y

end

obsidian grotto
upbeat tulip
#

Both the RealArrow and the hitmarker should be in the same ScreenGui

obsidian grotto
#

they are

upbeat tulip
#

Try the Overlap check function keeping the needle at a fixed position over the HitMarker.

obsidian grotto
# upbeat tulip Try the Overlap check function keeping the needle at a fixed position over the H...

local button = script.Parent
local FakeArrow = script.Parent.Parent.Arrow
local RealArrow = script.Parent.Parent.Arrow.Arrow
local HitMarker = script.Parent.Parent.HitMarker
local RunService = game:GetService("RunService")

local rotationSpeed = 200 -- degrees per second

function isOverlap(gui1, gui2)
local gui1Pos = gui1.AbsolutePosition
local gui1Size = gui1.AbsoluteSize
local gui2Pos = gui2.AbsolutePosition
local gui2Size = gui2.AbsoluteSize

-- Check if the boxes overlap
return gui1Pos.X < gui2Pos.X + gui2Size.X and
    gui1Pos.X + gui1Size.X > gui2Pos.X and
    gui1Pos.Y < gui2Pos.Y + gui2Size.Y and
    gui1Pos.Y + gui1Size.Y > gui2Pos.Y

end

button.MouseButton1Click:Connect(function()

if isOverlap(RealArrow, HitMarker) then
    print("yes")
else
    print("nope")
end

end) Changed it to this and still does not work

#

it still does not work without rotation

obsidian grotto