Тёмный

How To Drag And Drop In Godot - Basic Level Explanation 

Artindi
Подписаться 42 тыс.
Просмотров 22 тыс.
50% 1

I wish someone had explained the build in drag and drop feature in Godot the way I do it here, so I'm sure there are others who would appreciate it explained in this way as well. It's not very specific, but should be the most adaptable explanation. Enjoy!
Contact and Social Media:
Email: artindigames@gmail.com
Discord: / discord
Twitter: / theartindi
itch.io: artindi.itch.io/
Time Stamps:
00:00 - Intro
00:35 - How To Visualize Back End Dragging And Dropping
01:06 - The Built In Functions Overview
01:55 - Get Drag Data Function Explanation
02:35 - Drag Preview
03:20 - Can Drop Data Function Explanation
04:28 - Drop Data Function Explanation
05:18 - Recap
Music:
Music from Uppbeat:
"I Don't Need Your Love" By Adi Goldstein
License code: NQNGM3R6S374DLJE

Хобби

Опубликовано:

 

4 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 56   
@ceruleanserpent387
@ceruleanserpent387 3 месяца назад
Update for this tutorial- the functions require underscore now in front of them to work (godot 4 change). _get_drag_data _can_drop_data _drop_data And instance() is now: instantiate()
@MeowKiritoMeow
@MeowKiritoMeow Месяц назад
You're a hero
@Artindi
@Artindi 2 года назад
Hopefully this non-specific explanation will be helpful to a few people. Not sure, but if so I'll try to keep my future Godot videos in this sort of format. :)
@kittatro
@kittatro Год назад
This is a great format, thank you for this!
@MrShattuc
@MrShattuc Год назад
I would think as a native part of dragging and dropping, one should include how they got godot to recognize what they clicked on to kick off the process.
@bryno2932
@bryno2932 Год назад
This is perfect. Exactly what I was looking for. I agree that we need more non-specific examples demonstrating how to approach solving problems in general terms
@Artindi
@Artindi Год назад
Glad I could help! :D
@erobertwald
@erobertwald Год назад
Thanks so much for this. I was lucky that I found this explanation first. The generic approach helped me implement it in my game quickly. In my game, I had to split the code a bit or put the first function in the drag objects and the other two in the drop objects but your explanation mad it easy to determine how to expand to that. Bravo!!!
@Artindi
@Artindi Год назад
Happy I could help! :)
@benikeler
@benikeler Год назад
This vid helped me a ton in GD3. Found out from switching to GD4 the functions are nearly identical, just add a underscore in front of the func name and the 'position' argument is now 'at_position'. Ex. func _get_drag_data(at_position): You'll also see a signal icon pop up for the func if you did it right.
@dandymcgee
@dandymcgee 2 года назад
Love the little tilt animation and translucency, nice touches.
@Artindi
@Artindi 2 года назад
Thanks!
@VampireDGames
@VampireDGames 10 месяцев назад
Holy shit ma dude, you actually just provided me the explanation I needed, what a legend
@iroroistaken
@iroroistaken Месяц назад
Thanks just wat i needed
@anpesx
@anpesx 2 года назад
Awesome, i loved it.
@Lmfaocj
@Lmfaocj 3 месяца назад
Thank you for making this simple. This was what I was looking for. I can already imagine the many different ways I can sue this.
@KlausWulfenbach
@KlausWulfenbach 2 года назад
If you do a search for "Godot drag and drop inventory" there's a bunch of tutorials that cover these functions. Just in case you want more examples of what these could be used for.
@Artindi
@Artindi 2 года назад
Thank you! Exactly how I'm hoping my video will help: Just the basic explanation and now they can better understand all the tutorials and examples out there! :D
@PoenariMoon
@PoenariMoon 8 месяцев назад
omg thank you for the nonspecific examples!
@Artindi
@Artindi 8 месяцев назад
you are very welcome, glad I could help. :)
@EnormiE
@EnormiE Год назад
Hey man, great video. Do you have any idea how to use get_drag_data but with right click instead?
@Artindi
@Artindi Год назад
Nope. But ill look into it. If I figure it out I'll let you know.
@bluespider6537
@bluespider6537 Год назад
Sometimes all you need is something simple, thanks I never knew Godot has a built in function for drag and drop item TwT
@Artindi
@Artindi Год назад
Yeah, it's kind of nice once you understand it. :)
@jozef18591
@jozef18591 2 года назад
Nice tutorial bro
@Artindi
@Artindi 2 года назад
Thanks bro. :)
@JavaJack59
@JavaJack59 2 года назад
Seems like it would be difficult to make something like the olden times gee-whiz Mac OS X dock where the icons grew and shrank and slid around in proximity to the mouse, since control nodes all tend to get a fixed size inside their parent. Might be an interesting experiment.
@Artindi
@Artindi 2 года назад
Yeah, that would take quite a bit of logic for sure. And possibly other triggers outside of the built in drag and drop functions that activate effects as they sense the mouse moving around while dragging somethings. But hey, the more feedback you have the better for the player! :D
@Ninjakrom
@Ninjakrom 2 года назад
What are the 1st lines codes, from the texturebutton Gscript?
@Artindi
@Artindi 2 года назад
Mostly just default stuff when attaching a script to a node, or preloading a scene to be instanced, I really don't have anything special going on in there. :)
@TheBiggyJMan
@TheBiggyJMan Год назад
Great video, but how are you triggering these functions. Every time I drag, the sprite interferes with checking the room for an input event.
@Artindi
@Artindi Год назад
I'm not sure exactly what you mean, or what's causing that for you, maybe the way the sprite is ordered in the scene tree? Or maybe how your drag and drop item is built? I don't really know, just some shot in the dark theories. :)
@aciuvlad8634
@aciuvlad8634 Год назад
Hi. I'm working on a game in godot, sort of a simple game where you put some cards in order and I'm very new to Godot and i thought that it would be simple to verify if one card is in its correct slot. For example i have card 8 in slot 5 it there would be a red cross icon, and when you have card 5 in slot 5 you get a green check icon. But with this method I'm guessing you have to verify the texture data because the texture buttons dont actually move. You did mention this when setting minecraft as an example, but I can't figure this out and it took a couple of days until I've given up. I've tried making the buttons have their own script and trying to verify the path of the texture to be correct but I haven't found resources in the way of trying to make me understand how that is possible. Anyhow, if you have any idea what i could try I'd be more than happy. Thank you for the tutorial, very eazy to understand. Cheers nvm: figured it out.
@Artindi
@Artindi Год назад
Perhaps you could set up an array or dictionary behind the scenes that can have the "correct" order in it, that can then be used to verify a card is in the correct slot, with a check_slot() function that you would have to make yourself, thuis function could be called when a card is dropped. That's how I would probably approach the solution. Not sure if my response here helps though. :)
@Artindi
@Artindi Год назад
Oh... you said nvm you figured it out. Lol. Glad you found something that works. Lol 😆
@Trendsthismonth
@Trendsthismonth Месяц назад
Would be nice to have a downloadable
@aleksandradrobik1021
@aleksandradrobik1021 Год назад
Hi, I just used your tutorial and I am getting an error stating “the identifier “DRAGPREVIEW” isn’t declared in the current scope. Is there a way to resolve that?
@Artindi
@Artindi Год назад
I haven't heard of that before. And I'm not really sure how it might be fixed without seeing the code. If you want to join my discord and post it there I might be able to help you sometime. When I'm not at my job that is. :)
@aciuvlad8634
@aciuvlad8634 Год назад
Same issue here, im kind of noobish so I might have missed something. Fixed it! Just learned what instancing is, and I recommend if somebody has this issue in the future to also learn what instancing is!
@MMuraseofSandvich
@MMuraseofSandvich 3 месяца назад
The way to do it in Godot 4 is to preload the scene to a variable, and then create an instance by calling instantiate() on the variable.
@BHanif-zc2pr
@BHanif-zc2pr 2 года назад
Hi i want to record audio by my phone while there is sound and play when the sound is stop. Like talking tom. How can i
@Artindi
@Artindi 2 года назад
Boy, I have no idea, I suppose you'll have to figure out how to detect the volume of audio coming in and set like a 1 second timer to trigger when the incoming audio becomes quite. I've only ever worked with prerecorded sounds, but I have no idea if you can detect incoming audio volume, I couldn't see anything in the docs: docs.godotengine.org/en/stable/tutorials/audio/recording_with_microphone.html Sorry mate, might have to post it in a Godot forum or something. Let me know if you figure it out! :D
@BHanif-zc2pr
@BHanif-zc2pr 2 года назад
@@Artindi thanks for your response
@feedmind4669
@feedmind4669 2 года назад
can you make a screen panning tutorial?
@Artindi
@Artindi 2 года назад
Like when you move your mouse to the edge of the screen then the camera move as well?
@isotoxal
@isotoxal 2 года назад
i can't belive these functions existed i did the logic in _gui_input data for todot...
@Artindi
@Artindi 2 года назад
Sounds painful. O.o :)
@CrazyIemon
@CrazyIemon Год назад
Nice tutorial. Can you share the code for this?
@Artindi
@Artindi Год назад
I cannot. as instruction was covering only the main logic behind it, syntax can be found on the Godot Documentation under _get_drag_data(), _drag_data() and _can_drop_data(). docs.godotengine.org/en/stable/classes/class_control.html Sorry, but I do it this way because people tend to learn a coding concept better if they are forced to type it out themselves, even if it's just retyping a paused part of the video. :)
@kamleshbachani8132
@kamleshbachani8132 3 месяца назад
Bue then i cant show animations
@cclawhon4991
@cclawhon4991 3 месяца назад
SO close to being a dream tut. The idea is good, but you were too generic. Saying, "don't do what I did" is really frustrating without having a way TO do it. So, maybe put example code for two ways you might actually want to do it depending on use case? It would take 20 more seconds of video to give 2 example cases. If we don't know how else to drop it other than use the dictionary (bc you taught us that way), what do we do from there? So, generic is good but we have to be able to see specific cases or it doesn't make sense and we can't apply what we learned without desperately searching for that exact thing in another tutorial (and it's not given in another one using your methods). I appreciate the general idea, and hope you can find a happy medium. Also, you never show the top of your code at the beginning. A FULL scroll through would really help. Last thing: Sprite2D was random choice, especially if we have very specific things we are dragging using 3d controls...are you saying make new scenes for every different object preview? There's got to be a way to just add transparency to the actual thing we are dragging as the preview and not make a whole scene? I'm trying to adapt this but it is not easy!
@bonsaipropaganda
@bonsaipropaganda Год назад
why not just actually move the thing instead of just switching the data?
@Artindi
@Artindi Год назад
optimization, and this method is built in and is much more simple then most any method one might make from scratch. Depending on your game of course; something with a lot of dragging and dropping, such as a Minecraft like inventory, will most likely run smoother this way, but of you only need to drag and drop one thing, in a particular and unusual way, then making your own functionality could be best.
@bonsaipropaganda
@bonsaipropaganda Год назад
@@Artindi That makes sense. I ended up scrapping the mechanic entirely. too complicated in my particular scenario
@_jp_5
@_jp_5 11 месяцев назад
im having trouble instancing DragPreview.. I keep getting errors such as: Invalid call. Nonexistent function 'instance' in base 'String'. and The identifier "DragPreview" isn't declared in the current scope. here's what i have var DragPreviewClass = preload("res://DragPreview.tscn") var DragPreview = null # added this in the beginning of the script so maybe it would work but it didn't... var DragPreview = DragPreview.instance() DragPreview.texture = texture_normal add_child(DragPreview)
Далее
Smooth Drag N Drop: Godot Guide
9:28
Просмотров 44 тыс.
How To Fail at Knowing Who Plays Your Tutorial
0:41
Просмотров 35 тыс.
КРУТОЙ ФОКУС С ШАРАМИ
00:35
Просмотров 313 тыс.
Conquering fears and slippery slops on two wheels!
00:18
你们会选择哪一辆呢#short #angel #clown
00:20
Какую одежду я не ношу? 😱
00:13
Просмотров 444 тыс.
10 Minutes vs. 10 Years of Animation
19:29
Просмотров 279 тыс.
I Made My First Game in Godot in 3 Weeks...
26:21
Просмотров 226 тыс.
Tierlisting the BEST (and worst) GAME ENGINES
33:51
Просмотров 201 тыс.
Optimizing my Game so it Runs on a Potato
19:02
Просмотров 458 тыс.
How To Fail At Scale
0:44
Просмотров 11 тыс.
#shoot
1:00
Просмотров 9 млн