Skip to content

Draggable Nodes

Valk edited this page Sep 22, 2024 · 10 revisions

Simply add the [Draggable] attribute and implement IDraggable for any Node2D or Control node and it will become draggable in-game.

using Godot;

// Hold to drag and limit movement to vertical axis
[Draggable(DragType.Hold, DragConstraints.Vertical)]
public partial class DraggableNode : Node2D, IDraggable
{
    public void OnDragReleased()
    {
        // Do something with DraggableNode here!
    }
}
Clone this wiki locally