#Using node2d for drag and drop inside control node UI?

8 messages · Page 1 of 1 (latest)

brisk horizon
#

Anyone know if node2d mouse interactions can work inside of control nodes? Basically I have a computer screen in my game that's projected from a subviewport onto a mesh that is the computer screen. My mouse functionality works with UI buttons on the screen, but I also want to be able to drag and drop certain items within the computer's UI. I realize that this asset library demo exists (https://godotengine.org/asset-library/asset/2767), but I want a Balatro style drag and drop where you actually pick up and move objects. I've tried using a node2d, area2d, and staticbody2d as the root of the draggable object, but the mouse_entered and exited signals dont work. When I add a texture rect as a child of these though, the misc tab in the debugger shows that I'm clicking the texutre rect, but still the mouse entered/exited signals do not fire for the parent nodes collision body.

modest grotto
#

If you want to detect clicking and such, it may be worth looking into using Controls for that purpose. _gui_input() is pretty good for detecting mouse actions specifically on a certain control node, so they've always been my default for click-detection

brisk horizon
modest grotto
#

Why wouldn't you be able to drag around a Control node?

#

I don't believe there's anything about Control nodes that prohibits that functionality

#

They can be moved and rotated

brisk horizon
#

I guess I'm misunderstanding that part of control nodes. Every implementation of drag and drop I've researched has used control nodes for the kind of drag and drop from that asset library link, whereas all the implementations of a free drag and drop I've seen have used 2d nodes.

#

Take a simple drag and drop TicTacToe game built in the Godot game engine. Implemented once with UI Control nodes and once with Node2D nodes. We compare and contrast the differing drag and drop implementations for each version.

Reviewing these simple examples will show you two ways to approach drag and drop in Godot 2D games. You can use thi...

▶ Play video