Hi everyone!
I’m having trouble with my inventory drag-and-drop system in GDevelop (copy from this one https://gdevelop.io/game-example/free/inventory-system), and I can’t figure out how to make item swapping work correctly between occupied slots.
The system works fine for basic drag and drop.I can pick up an item from a slot and drop it into an empty one without issues.
The problem starts when I try to drop an item into another occupied slot.
When I do that a secont time, the dragged item should swap places with the one in the slot like at the firts time.
Instead, the item in the pointer disappears visually (although it still exists in the inventory data, so I know it’s not really deleted).
Basically, it works once, but if I try to drag again or drop it back into the same slot, the logic breaks.
What I want is a proper swap system :
- If both slots have items, they should exchange their contents.
- If the target slot is empty, the item should just move there.
If anyone has a clean way to handle this (or an example of working “swap slot” logic in GDevelop), I’d really appreciate it!
Thanks in advance!