How to Create a INVENTORY in Godot 4 (step by step)
Вставка
- Опубліковано 15 жов 2024
- This video is a step by step process to creating an excellent well working inventory system in Godot 4, I spent a long time trying to figure out the best way to create the most functional and efficient inventory system in Godot, and after a lot of research I’ve decide this is the best possible way in my opinion so I wanted to share and make a tutorial on the step by step process of how to create it and wanted to teach you how to implement this inventory system for your own Godot game.
Link to Part 2 of the Inventory Tutorial: • How to Create a INVENT...
Link to Series Art: devworm.itch.i...
Link to Complete Survival Series Playlist: • How to Make Survival G...
Thank you so much for watching, if this video helped then please hit the subscribe button and drop a like on this video so you can help me get this tutorial in front of more aspiring game developers, so they can learn to create their own Godot games as well. Stay Safe and have a wonderful rest of your day!
took inspiration from other youtube tutorials on the topic and combined ideas to try and explain this 2 part inventory tutorial series in the best possible way.
Link to Part 2 of Inventory Tutorial: ua-cam.com/video/fyRcR6C5H2g/v-deo.html
This is Episode 4 of the Survival Series.
Complete Survival Series Playlist: ua-cam.com/play/PL3cGrGHvkwn2NOT1LSwf5d2XZmlc5Bjsn.html
Hope this series helps!
Help is a small word.
Bravo.
Yet again you cover something very "basic" for a functional game and you provide with tools to create a quick inventory system that feels so satisfying to test in your own project. I will also admit one thing, which is the fact that even your mistakes were important because they helped me search and identify the mistakes myself, which helps improving your understanding of the code. Again thanks a lot for all this, really appreciated!
thank you so much for that! I am so glad everything came out perfect and was able to help you understand and learn! searching for the mistakes is so important but so annoying at the same time lol!! thanks! and if you ever need anything at all then please let me know!
Your tutorials make everything so simple and straight forward, which is exactly what I need when I'm starting out. Maybe there are "better" ways to do things, but if I can't understand why it's better I'm not learning, so this is perfect.
video quality stunned me into commenting. incredibly clean and concise. you knew what we wanted when we searched for a tutorial like this and delivered perfectly. not much like this around these days, keep it up
Thank you. I have watched many videos on Godot Resources and this was the first one that really made it all click for me. The work flow simplifies so many things that I have been frustrated with while working on my game.
so glad to hear!!
Thank you for sticking with godot tutorials, it means a lot to junior developers like me! love from china
of course!! So many more are on the way soon! I'm so glad Im able to help.. if you need anything then please let me know!
Wow 😳from china
Looking forward to it!@@dev-worm
Perfect. This is EXACTLY what I needed, step by step, no bloat.
so happy to hear! thanks!
Hey there! I’ve been watching your videos for a while now. You’re a REALLY great teacher and deserve so much more subscribers.
I also really appreciate when you make little mistakes or hiccups. Sometimes with new devs, we don’t know that it’s okay to make mistakes or how to debug, so seeing you make little mistakes and work towards solving it is really helpful and wholesome to see.
Really much looking forward to more videos. Hope you’re not overworking yourself, just wanna say I genuinely appreciate your channel and work
Great tutorial! You spoke a little bit quickly. I was able to follow you, but the video felt a little rushed as a result. Everything else was great! There was a clear through-line for the tutorial, and I liked seeing the errors, as that's how regular programming goes, you never get it perfect the first time. Very helpful for my own project, thanks!
so glad to hear!! I am sorry it was a but quick! I will take that into consideration for future tutorials!
I really like this aproach for making reusable inventories with that kind of "interfaces". Thank you.
I'm super new to game dev and just get in the first 5 minutes and it cost me like 4h to understand the codes you are using even i watched all of your previous tutorials and now I can understand more things about coding. Thank you very much.
Just what I needed! Thanks a lot man you rock
so glad to hear you found what you needed, and so glad that I was able to help!
Excellent tutorial. No fluff, straight to the point.
glad to hear!! hope it was helpful!! thank you!
Finally new video, I'm already waiting for the next!
next one is coming very soon!!
Bro woke up and chose to make games..
Really appreciate you efforts
haha thanks!! hope it helped!
Hey. Any chance you plan on going as far as making a hotbar where you can drag items onto? Inventory/Hotbar systems are where I am most stuck right now. I also have a spell book and plan on having those also draggable onto the hotbar, but I can probably figure that out myself when the rest is figured out lol
just came across your channel, 5 stars. you break things down nicely for us coming over to Godot.
I don't normally like video tutorials, but this one was super helpful. Thanks for the content!
Glad it was helpful! thank you!
This is really nice. I was working on a game where the player has a "phone" and could gain apps to control things in the game world. This works perfectly for the UI.
Amazing video and really clear as always
that sounds like a really interesting idea!! id love to play it some day! thank you I am so glad to hear it helped!
As you already have a local variable like "is_open", you don't need further functions for opening and closing the inventory.
This is how I did it (first part of the inventory creation):
class_name InventoryUi extends Control # I think class_name should be before the extends
var is_open = false
func _ready():
visible = is_open # starting as false
func _process(delta):
if Input.is_action_just_pressed("inventory"): # I like names like "inventory" instead of "i"
show_inv()
func show_inv(): # no need for separate functions open() and close() - reducing bugs
visible = !is_open
is_open = visible
Less lines of code is always better 😅
Your suggestion is fine, but I can't get behind the 'less lines is better' line of thinking.
More lines is better if it means your code is easy to understand in the future. Do not underestimate how much time you will sink looking at your own code on any larger project.
@@Nezarus0 Sorry, I switched to "Ants Godot" (my new Godot channel) and haven't seen your comment earlier.
You are right: short code might be too confusing. I meant the "keep it simple, stupid" (KISS) paradigma. Don't use additional variables if you already have the visibility that you can toggle, just as an examample. I also like code that you can read without comments and prefer:
for line in text...
rather than:
for i in s🤣
per-usual awesome video. Only thing I had issues was the importance of saving the scrytps before looking for the resources. thank you again my dude
You explained this so well! Thank you for explaining everything in a simple way and not just rushing through the code
so happy to hear! thank you! of course that my only goal.. to make understandable un-confusing tutorials!! so happy they come off that way, it means the world!! thank you @msilva1999 and if you ever need anything then please let me know!
@@dev-worm thank you! 😊 I'll keep watching your videos to start making my first attempt at a game hehe
Keep up the great work!
YOU DROPPED THIS 👑
Hello everyone,
I'm from Germany and my English isn't that good, so I have a hard time understanding what you're saying, but I like to watch how you do it, it's great. One question, are the 2 videos with loading and saving the Idems? I just started with Godot, I'm 59 years old, so it's not easy.
Best regards
You are incredible teacher 😍
Thanks!! it means the world to me!
Very good explanations and practical solution, thanks! I can see it can be quite useful also in creating a strategy construction or unit recruitement menu UI.
Your channel has been very helpful and has been a great stepping stone to my own project! Thank you!
so happy to hear!! thank you so much!
Excellent! Very detailed, not too fast and not too slow. Subscribed right away!
so great to hear! thanks! if you ever need anything then please let me know!
you're a legend. subbed. thanks man
thank you it is a really quick tutorial that save a lot of time
so glad to hear!
The Inventory System Part 1 video works perfectly well for Godot 4.2
So far, the one and only video that I was having problems with was episode 1 for setting up the walking system for walking in all 8 directions. Besides that, the rest of the videos (including this video) worked perfect for me with Godot 4.2 :D Can't wait to finish the inventory system in Part 2!
glad to hear!! sorry about the 8 directions system, I dont know what could be wrong! if you run into any issue is the next episodes then please let me know!
@@dev-worm after finishing Part 2, the inventory system itself works perfectly well. But I got visual issues such as Ysorting not working the way it’s supposed to work.
Yay thanks thank you so much
of cource anytime! If you need anything then please let me know!
@@dev-wormcongratulations on 10k🎉
hopes to see the second part soon !
coming very soon!
Amazing tutorial series! I hope you can keep going! I rly would love to see add a craft system or something like that!
crafting would be really cool!! I might start working on that!
Omg he might do crafting, I need this (wanna make a game where you brew coffee, and crafting is kinda important for that)
love you man you are the best!
thanks that means the world! Glad I was able to help!
You are doing a good job. I like your stuff, but mine seems to have gone wrong and says I can't preload? Do you make troubleshooting videos?
Awesome, helped me so much! Great video.
awesome to hear!! thank you!!
Congratulations for 10k ❤❤in advance
Thank you so much!! Jeremiah, I see you all the time in the comment section and I just wanted to thank you so much for putting the time and effort in to help me out! I smile all the time when I see your comments and It truly makes my day! All love to you brother, it means the world to me! Im wishing the best for you in everything you do! Have an amazing day!!
@@dev-worm 😍😍
thanks for your tutorials brother they're great
so happy to hear!! thank you so much!
it works,thanks!!
so glad to hear that!
Bro why was it so funny listening to your voice changes when you were making mistakes xD
I gotta say...I've "been around the block" in terms of seeking out clear tutorials...and I keep coming back to DevWorm (and I'm a fan of the mid-Atlantic accent...somewhere between Philly and Baltimore if I could venture a guess). Anyway, really great stuff here!
ah man! means the world!! more south and in a bigger state... maybe you could guess now lol! But it means the world!! thanks so much and I hope you keep finding the content helpful!
Do you have any resources for how to create the use of inventory items in a combat/NPC event...for instance, I have binoculars in my inventory that add +2 to the success of this NPC event?@@dev-worm
...as far as guessing a state..I really had it pegged in the DelMarVa (Delaware/Maryland/Virginia) Peninsula...maybe venturing as far south as NC? Anyway, no need to tell me as online privacy is important.@@dev-worm
13:42 if u do control d it duplicates the choosen slot :)
Variant close invenory from button, open from signal 🤩:
func _input(event):
if event.is_action_pressed("inv"):
$".".visible = true
func _on_button_pressed():
$".".visible = false
looks amazing!
@@dev-worm You didn't make slots in the character. If this is not the case, you can simply store data in variables. Inventory is not necessary then
Nice Videos! It‘d be really cool if you‘d build on this one in a regular one, where you make a hotbar…
you could turn this into a hotbar view.. or create a different view of the same inventory into a hotbar
@@dev-worm Oh Wow, thanks for responding, I’ll give things a try, although I‘m still pretty new, but I‘m learning…
Edit: I made it work now, things weren’t really as hard as I thought it‘d be now, I‘ll continue your tutorials and try making items dragable.
Thanks again
Nice one! Thanks a lot for this. How do you handle saving the game state including the list of items in the inventory?
working on a save and load game data video right now.. going to try and upload it tomorrow!
to toggle inv visibility you can simply call a input function. inv.visible = !inv.visible
8:25 why are you putting this under _process(delta):? Doesn't that make the game run this check every frame of the game? That seems like a needless waste of resources to have the game checking each frame to see if the inventory menu key is pressed instead of just making it a func _input(event): which doesn't react until the correspondingly scripted input is provided.
yes you are correct! that would make a little bit more sense lol, sorry I shouldve caught that!
Thank you so much.
For making such amazing tutorial.
❤
But had a question that This should work on godot 3.5 right?
um. i don't think so, maybe if some things are changed but some of the functions used are in Godot 4 only. Thank you, sorry for this issue. I hope you are able to work around it.. if you are having issues then let me know and maybe ill beable to help!
@@dev-worm well I tested it and did not work as you shown but maybe if i see more other tutorials i could figure it out.
🙏💕Thank you
Keep up the good work ❤
thank you so much!
good video! How can I make sure that when I select it in the inventory, the apple is removed from the inventory and regenerates life?
Great instructive videos! Can you also make a video on how to create different playable characters? (Like in brotato for example)
Hi, this system can be added for a character sheet (equipement, stat...) or this is another method for this? (sorry for my english is'nt my native langage.)
Its giving me a error message on the inv_ui.gd part on for i in range(min(inv.items.size(), slots.size())): its saying: "Invalid access to property or key 'items' on a base object of type 'null instance'." dose anyone know why?
Could you please upload the inventory images? They have not been added to the description
Does this work on godot 3? Cuz im too far gone to use godot 4 so uhh... Ye
ah im sorry this doesnt work in Godot 4... inventorys in Godot 3 are gonna be a little more complex!
I’m getting an error at 18:27, it says
“GDScriptNativeClass” cannot be assigned to a variable of type “Texture2D”
Anyone else have this issue?
for anyone wondering why their images are blurry, you can click on the texture setting and change the filter to nearest.
you sir are amazing
How do you keep the inventory texture from distorting if enlarged?
I ran into trouble in the inv_IU_slot.gb around 18:24. Specifically this line item_visual.texture = item.texture. The error reads Invalid get index 'texture' (on base: 'Nil'). Anyone else run into this?
I watched it in x20, cool btw.
21:42 I have problem that my apples won't show and I can't figure out what could cause the problem
Same here, but I can't find any errors. Have you solved this yet?
I managed to fix my issue, somehow i got the inventory and inventory item resources mixed up. Not sure if it was a godot issue because my apple was somehow made using the player inventory resource. I just remade my resources and it fixed the issue
Hello I have a problom displaying the item can I please get the whole code to see where is my problem
OK so how about if an item is going to occupy multiple places in the grid with different sizes/shapes like Diablo?
At 23:10 instead of making a Center Container and Panel, couldn't you go to Offset and unselect Centered?
❤thx, great video
x20 seems really fast lol!!
Great code! But idk how to access an item later to drag and drop it into different slots
I am actually currently working on a updated inventory system which will include that!! It will be the crafting/building game series! With will be coming out very soon! And I think it will be a huge help to you!
finally!!! a new video
Can you ZIP all your assets and then upload it on itch? It's a bit tedious to download every image individually? Thanks in advance!
yes i’ll go work on that now and get it fixed for this and all the future ones as well i apologize!
@@dev-worm No problem!
Thx for video ❤
thank you! hope it helped!
is it possible to store diffrent types in the array , i wanted to make diffrent classes for diffrent item types, like usable and consumable, now i just gave them a enum , but would prefer classes, could also not figure out how i cam use superclass and subclasses , so o can just put the superclass in the array but with the advantages of subclasses
thx man
Quick question: Why did you add the panel @ 11:36, and then make its alpha value invisible, when you could just use a sprite without a panel behind it. I'd love to understand what panels do.
Thanks!
I am still very new to all of this, but in unity, UI elements were their own thing that interacted with each other, and maybe godot is like that where you need to use these green UI nodes so they play nicely together.
where is the link to the textures? they arent in the description
maybe make a tutorial on the mechanics of point and click games like e.g. Cube Escape
I don't have the option to pick resource from the inheritance search when trying to add a script.
Ive never seen that happen before.. thats weird.. sorry to hear that, did you try restarting the engine maybe?
Rebooting the program/project fixed it for me. InvItem didn't show up before hand and now it does. Thanks! @@dev-worm
Mistake I made while programming
was naming the ready function "func ready()" lol I was like why is not being called
Bro, i searched for the same mistake for like 2h. Thank u sir!
Thank you, I was stuck 😭😭😭😭
im 90% sure u never show where to declare the visable var so nothing works past the 8 min mark. or im stupid idk
visable is something godot uses, u dont declare it
another great tutorial, but i have one problem i cant solve. When i start the game, my inventory is already showing and the apples wont show in the inventory. and i dont know what i missed. i rewatch the video a few times now. if someone can show me what i did wrong it would be a great help
i learn ue5 for 3d game, and godot for 2d game. godot is easy and friendly 🤣🤣. Thanks
By the way, Y sorting and the hud seem to not mix, the hud is going behind all the trees, I hope this gets fixed in the next video.
-hey, i'm making a game where the character rotated according to the mouse, anyway i can not have the UI rotate with the character.-
Edit: turns out just throw a canvas layer on to the player character.
glad you figured it out! happy to hear!
Thanks!
you're an absolute legend! thank you so much!
The inventory slots keep overlapping when i instantiate my slots into the gridcontainer for my inventory background what do i do?
What?
É a mesma coisa para o 3d?
Will ut work on godot 3.5?
i am getting this error (Export type can only be built-in, a resource, or an enum.) when i am trying to make inventory resource pls help :(
save and then reload the godot program and see if that works.. sometimes I have to do that and it works.
Thank you so much I will definitely try it 😀
Can u make melee fight aimations tutorial like mortal cmbat.
ill look into it soon!
@dev-worm I tried to make a mortal combat but with swords, and I'm stuck on detecting combo and playing the right animation with normal transition.
HELL YEAH LETS GOOO!
part 2 is coming tomorrow!! I hope the tutorials are able to help you out @HippocritterXD
@@dev-worm most definitely, I get very excited when you upload a new episode. You are a great teacher
Inventory time \o/
goodluck!! if you need any help just let me know!
Buen tuto
seems it deleted my comment asking for help, assumed spam maybe?
to reply to the first comment of mine, Invalid get index texture (on base: Nil). is the main red error
I fixed the error les go
How did you fix it?
Nevermind I figured out the issue to mine. It was just I forgot to put the ‘!’ In “If !item:”
@@ChukwudaluDumebi-Kachikwu \Yes that was how, sorry for late response
@@ChukwudaluDumebi-Kachikwu holy crap, thank you, I've been digging over my code for almost 30 minutes trying to see where I went wrong.
nice
Bro i write chapters to video how to animated tiles in godot copy it and paste it in description and the video will chapter
Chapters of video how to animated tiles in Godot
Intro 0:00
Edit size screen 0:13
Making tilemap 1:03
The tutorial 2:05
Final look or the result 4:52
Outro 5:05
Solo puedo decir algo, no entiendo que dice pero me puede dar una idea y espero me sirva
More tutorial 😊😊
part 2 for the inventory is coming really really soon!
@@dev-wormLOOKING FOR TO IT😊
Hey, could someone help me? It's showing up with Parser Error: Could not find script "res://scene/world.tscn::G0Script_cdk0w" im unsure how to fix it 18:55
YEEEEEEES
Would anyone happen to be able to tell me what i missed that made the item_display go to the center when 0,0 transform was updated at 23.24, it goes to the 0,0 of the canvas
Incase anyone else runs across this, i had the item_display under CenterContainer instead of Panel