Skip to content

jeroenheijmans/sample-godot-drag-drop-from-control-to-node2d

Repository files navigation

Sample Godot 4 Drag & Drop between Control and Node2D nodes

This sample demonstrates how you could Drag & Drop items from a Control node, to either another Control or onto a Node2D (via a SubViewport).

Notes

Be warned! This repository:

  • Was created while learning Godot 4, and is not "expert advice";
  • Will likely not be kept up to date;
  • Might have differences for Godot 3.x and earlier;

Still, it might help someone!

Demo

This is what it should do:

sample-godot-drag-and-drop-between-control-and-node2d.gif

I found this Question without any answer, and wanted the same thing. I'm a beginner with Godot but still came up with something that works, not sure if it would hold up or is proper. Disclaimers out of the way, here's my solution.

The essence

The essence of the repository linked above is:

  • Encapsulate the Node2D stuff in a SubViewport node that's again a child of a SubViewportContainernode;
  • Implement the _drop_data(...) function on the SubViewportcontainer;
  • Make it "drop" the actual stuff as a child of the Node2D stuff

See the various scripts for how this works:

About

Shows how Godot Drag & Drop can work between Control and Node2D nodes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published