Newbie to Godot here. My idea is to create a deck building game, inspired by Slay The Spire or Across the Obelisk. I have come to a problem that I can not seem to find the answer.

So, the card object is complex: it consists of multiple things (textures for card frame and card front images, texts for card name and card category). Something like MtG type of a card. The issue is that the cards should also be draggable.

I found tutorials and examples online how to implement drag and drop in Godot, but they always show how to move a simple object like a sprite with one texture or a colored rect. No idea how to move an object that has a lot of children inside. My attempts to drag containers or controls were not successful.

Is there a way how to do it? Or is it better to preload all the textures and texts for the card and 'combine' them in one texture to drag? If so, how to do it correctly?

  • \$\begingroup\$ Welcome. It helps if you could include a specific, re-creatable example of what you're trying to move. As you said, there's info out there for Godot drop & drag - if the common solutions aren't working, then seeing exactly what you're trying to move will focus answers on addressing that rather than rehashing the simple scenarios you've seen that don't work for your situation. \$\endgroup\$
    – Pikalek
    Commented Oct 2, 2023 at 18:49
  • 2
    \$\begingroup\$ What was the issue you encountered while dragging a Container? \$\endgroup\$
    – Theraot
    Commented Oct 2, 2023 at 21:32

1 Answer 1


You could make the card be a separate scene with a node2D as root. I don't know how you want to implement dragging and dropping but here is how I would try to do it:

(this is all in the card scene)

Add a Area2D node and a collisionshape2D as a child of the area. (don't forget to also set the shape you want!)

Add your sprites/textures (I just used multiple copies of the godot logo as an example)

Add a script to the root node in the scene.

This is my script:

extends Node2D

var mouse_overlap = false
var dragging = false

func _process(delta):
    if mouse_overlap and Input.is_action_just_pressed("LMB"):
        dragging = true
    if dragging and Input.is_action_just_released('LMB'):
        dragging = false
    if dragging:
        global_position = get_global_mouse_position()

func _on_area_2d_mouse_entered():
    mouse_overlap = true

func _on_area_2d_mouse_exited():
    mouse_overlap = false

The func _on_area_2d_mouse_entered(): and func _on_area_2d_mouse_exited(): are signals from the Area2D connected to the script. You can add signals clicking on the Area2D and going to the node tab (over in the top right) and double clicking the signals func _on_area_2d_mouse_entered(): and func _on_area_2d_mouse_exited():.

node tree in the card scene:

node tree

Finally, add the card scene to your main scene.

Final result: (you can't see the mouse because It's a screenshot)

enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .