Drag and Drop Godot 4

preview_player
Показать описание
Implementing Drag and Drop using the Control node's built-in functions,
It's mainly used in making inventory systems for slots.

- Code -

- Music Used -
- Hoogway x Softy – Words on Water
- Provided by Lofi Records
Рекомендации по теме
Комментарии
Автор

Yes the texture disappears if you drag and drop it outside, I set the previous node to null that was causing the issue, instead we will swap between two nodes, that will solve the problem, I made an update video + a whole Inventory system, if you are a future viewer here you go

bitdev
Автор

This is the most calming programming tutorial ive ever watched

TheOGRizzlyBear
Автор

I appreciate how short and to the point your video is! It is a great resource when looking for techniques I haven't implemented yet!

mr.bloopbloop
Автор

I've probably tried at lteast 4 different methods to do this, but this simple tutorial is the only one that I understood fully and that worked like it was supposed to. Thanks!

beautyisntperfect
Автор

I've watched 3/4 tutorials for drag and drop. Yours is the best.

Korboh
Автор

Great, simple solution, straight to the point

jumpsneak
Автор

this is the best and simplest implementation ive seen, just using these built in functions is really smart

trainzmarcel
Автор

as someone just getting used to making things that do thinks, your tutorials are great! Than you for making them

parkerpierce
Автор

From my understanding the built-in function only generates an event when a "Draggable" satisfies the _can_drop_data requirements, i can highlight a Slot objects when _can_drop_data is fired, but nobody tells me if the Draggable is not hovering anymore...

papatagi
Автор

Thank you. So simple example and explanation.

randalllasini
Автор

Thank you for your tutorials! 1:39 Could you help telling me the meaning of adding "var preview = control" ?, i found that i can ignore it to get the same result 🤔

rockyhitcha
Автор

There is a slight problem with this code though - if you leave your texture anywhere else other than the designated spot, it just disappears, and cannot be recovered

rameoparmon
Автор

[TIP] if you wish to have the texture at the center of your mouse, or any other position than the top left corner, after you do the just set the position of the preview_texture to a new vector2. Hope it helps someone

robert_just_a_byte
Автор

If you release the preview outside the panel, it simply disappears, how can I recover the texture?

yusarimahubara
Автор

Hi, thanks for this tutorial. If I want to swap ItemA in TextRect and ItemB in TextRect1 after dragging ItemA to drop in ItemB, how should I amend the code to reflect this swap?

coldmantou
Автор

sprite2d mouse pressed stay if you drag beyond viewport and come back... any solution?

babaamar
Автор

hey, I have set my window's Stretch setting to 'keep', and it made the texture while dragging end up like wayy off my cursor. anyone have ideas on what went wrong here?

bowl
Автор

hey but when inside the inv when u put the item outside of the inv it just dissapears in to tin air

The_sky
Автор

Then How do i make it snap??? like if the sprite is outside the boundary, it will go back to its original position?

bugoman
Автор

keep making this tutorials they are very good

haiden