I am making a game with inventory system. I also made a hotbar, but i dont know how would i detect when item got collided with ui hotbar slot.
Is there anyway to check if both frames colliding? I am using UiDragDetector for the dragging atm.
I am making a game with inventory system. I also made a hotbar, but i dont know how would i detect when item got collided with ui hotbar slot.
Is there anyway to check if both frames colliding? I am using UiDragDetector for the dragging atm.
Hi! Could you perhaps send a screenshot of the issue, it is a bit difficult to visualize.
only thing i can think of is, do
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local list = game:GetService("StarterGui"):GetGuiObjectsAtPosition(mouse.x, mouse.y)
local itemThatIsDragging = (put the instance of what the player is dragging here)
local item = table.find(list, itemThatIsDragging)
if item then
print("item is touching hotbar")
end
Its not hard to visualize for me
Basically he wants help with inventory system with dragging
Like he can hold mouse on item in inventory, drag on slot and it will equip it
Use this basic function to check if they overlap
function IsOverlapping(f1,f2)
local f1pos,f2pos,f1size,f2size = f1.AbsolutePosition,f2.AbsolutePosition,f1.AbsoluteSize,f2.AbsoluteSize
local xoverlap = (f1pos.x <= f2pos.x and f2pos.x < f1pos.x + f1size.x)
local yoverlap = (f1pos.y <= f2pos.y and f2pos.y < f1pos.y - f1size.y)
return xoverlap or yoverlap
end
Oh, I see that makes sense, in that case, I would do what @MysteryX2076 did to check for overlaps (simply defining boundaries).
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.