Robust Drag and Drop functionality

I’d like a behavior or expression that handles drag and drop interactions at a similar depth and complexity as physics/platformer interactions.

I have a portion of my game that involves dragging objects to locations and dropping them there, but only if they match certain criteria.

I’d love to have functionality and an interface in GDevelop that allowed me to easily specify the conditions under which that object successfully drops to that location, is rejected from that location and goes back to it’s location before the drag, kicks out another object in that location and send that back to it’s location before being dragged there, as well as related movement and effects.

I think I’m going to be able to cobble together a way to make this work using Draggable and CancellableDraggable, but it involves more work than I expected and the more I patch together something like this the more likely I’ll introduce errors.

I’m requesting this because Drag and drop seems like a common interaction type. The stronger it is in the engine, the easier it will be to use it.

Some typical use cases would be dragging equipment to a character in an RPG inventory screen, dragging a letter tile to a scrabble-like word game, dragging a chess piece to a square, or dragging a card in a solitaire game.

(I’ve seen people accomplish those with Gdevelop, but when I look “under the hood” they all look fairly complex and unique.)

1 Like

How do you picture it to make it less work?

I might mangle the terms, but something like this:

  • A behavior I can attach to a drop zone and a behavior I can attach to drag object(s).

  • A way to specify within the behavior whether the object is accepted or rejected by the drop zone. Does this object match the drop zone criteria. (i.e. only “1 handed weapons” may be dropped in this weapon drop zone, not “2 handed weapons” or “chest armor”)

  • A way to handle kicking out an object that is currently in the drop zone, if the drop zone can only have 1 object at a time. (i.e. If weapon drop zone already has a weapon placed in it, it is moved to new location / drop zone when new weapon is dropped there)

  • So a way for users to then use this behavior and logic in events. “Activate drop zone behavior of weapon 1” or “Reject drop” or “Set drop criteria to fruit” or “When drop is rejected display X and make sound Y” or “If drop on drop zone X is successful then do Y with drop object”

1 Like

Hi ChellaP,
sounds like a brilliant project, which I fully support!
The drag and drop behaviour of gdevelop is indeed very basic and requires to build a lot of custom behaviours for the most basic drag and drop events, which you describe very well.
Working on drag and drop games myself, I’d be happy to try out your system and contribute if I can. For instance, I’m putting in place a custom drag behaviour allowing to customise the speed by which objects are dragged (using lerp). Already working but not fully debugged and implemented.
Anyway, keep us informed and good luck :v: :slight_smile:

1 Like