For those having trouble initializing the ScriptableObject. I had a problem when I started creating the FoodObject everything was fine but when I clicked the values reset. It was because I used the Awake function. When you click, the object is reset because unity calls the Reset() function. So if you want to fix overwriting values, use Reset() instead of Awake(). This worked for me.
If you've stumbled across this video randomly while trying to find a good tutorial on inventory system in unity, you've found what you need. It's a little complicated at first, and there are a lot of rewriting that will be done in the next videos, but it worth it in a long run and you actually learn something following these videos. So thanks for these videos, i hope you'll be able to make new videos again soon!
Does he eventually address the limitations of enums? Not that I am complaining, this is good information, but the enums is a limitation for creating a dynamic "item" system.
Just make sure you always pick the right names for the fields and never change them again, because renaming a field inside of a SO will cause you to lose all your data. That's one nasty thing they rarely mention about SO. You rename a field, and your data is permanently gone (unless you have a copy, of course). So you need to use the horribly clumsy way with [FormerlySerializedAs] attribute, which is reminiscent of programming in 1970'es. Instead of adding a rename option directly n the inspector.
I watched so many tutorials on this subject. The one by Brackeys, Sykoo, Code Monkey, Blackthornprod... This one is by far the best inventory tutorial, and the only one that I fully understood.
This is hands down one of the best tutorials I've seen on this. Simple straight to the point organized (strangely rare in these Unity tutorials) and from what I've gathered so far extremely flexible. I don't even plan on making an RPG I wanted something for survival horror game and this is perfect.
I went into this extremely pessimistic. There are some very clunky and outdated tutorials on making Inventories and Interaction systems on youtube, but i had to pause this video despite being only 15 minutes in. In these first 15 minutes alone I've learned more than the hours of clunky, messy outdated tutorials i've watched on the topic in the last few days. Thank you so much! Please keep doing what you're doing and making awesome tutorials! I feel by following along I'm actually learning so much more about unity's systems that I didn't know before or how to make use of it better. Thanks a lot! Instant sub!
I finished the entire series a few weeks ago, and I came back to the first video, where my comment will have the most impact, to say, THIS TUTORIAL IS WORTH EVERY SECOND. My game received a huge upgrade from what I learned in 9 parts. if you've been searching for an inventory tutorial video this is THE ONE. (didn't mean to sound like a TV salesman, but i just got this thing to work with the gamepad, I no longer have to touch the mouse at all, and I'm through the roof right now)
You got it to work with a gamepad! Could you maybe tell me how you did it? I'm hoping to make an inventory that way cause I want my game to have a retro, played on an old Playstation, feel with no mouse.
@@mysteriz_madi it’s been a year so I don’t know exactly what I changed to be able to do that however I do remember that I had to copy most of the mouse code and rewrite it for use with the controller. I’m not exactly an expert with coding, so I think you’ll be able to figure it out, but as of now I’d have to looks through the scripts to find out what I changed. I believe the majority of what I changed is in the userInterface script. Start with changing the click to a button press, you’ll need to make another gameObject variable similar to the one that holds the item when selected with the mouse. All I really did was copy all the input functions and refit them so that they can work with a controller. Recently I managed to break something (after it was working for the better part of a year) and the mouse no longer works properly, which is why I’m not sharing the exact code.
Just chiming in to say this was the most in depth tutorial I have found on implementing this and it really helped me a ton. I really appreciate getting right to the meat of how to accomplish this, without spending a lot of time talking about useless bits.
I'm half through this and this is the first Unity content creator I feel obligated to Subscribe to. I'm so impressed at your delivery of information. I've done non stop tutorial/lesson surfing the past couple weeks and this one casually covers many of those I've seen with so much ease... and more. Half way, easy subscribe. I'm just hoping when I click your youtube page I see even more content! Big thank you.
Thank you for this. As it turns out, what I needed to solve the issue I was stuck on in trying to make an inventory system from scratch myself was constructors, which I somehow didn't encounter or learn about until now. I don't think you really explained what that was in the video and at first I didn't understand it, but I looked up "constructor" in the C# docs and now it makes perfect sense and makes this whole process much, much easier.
Not only has this helped me plan out my inventory system, it's helped me solve another little headache I've been having which is how to store images in scriptable objects I need to serialize! Kicking myself I didn't think to just use prefabs... So simple! Thank you!
its been 3 years but it helps me a lot on making inventory, thanks coding with unity, i wish you all the dreams that you had become true, thanks love you
I'll join the many comments that already praise this video and say that to me this was also one of the best videos at explaining inventories for beginners. Learnt everything I came here hoping to learn and more. And then I found out there are 7 more tutorials on the series covering everything about inventories. Amazing. I'm going to watch them now and will update the comment with my opinion when I finish. Edit: Finished the series. Followed every step and everything worked. I learn A LOT more than I expected about unity and C# features and managed to implement the inventories I wanted in my game. I also did some adaptations and refactored some of the code so that the names made more sense to me. This is a deep tutorial and I had to watch some videos once without writing, then another time following along so that I could get the bigger picture before focusing on the details, but it was worth it. Almost everything gets improved in the next tutorials and many bugs that appear along the way are eventually fixed. The final system is perfectly usable in-game. The creator is charismatic and makes it entertaining to study. Overall, recommended.
@@daryll4645 Well, I'm on the last video of the series and I still think they are great. Maybe not for everyone, but they are exactly what I was looking for. I watched many videos by bigger youtubers but they didn't go into enough depth to allow me to add the features I wanted to add to my game. These ones did, and at the same time, they improved my understanding of unity features such as scriptable objects, abstract and static classes, inheritance, event triggers, and serialization. They have their faults (a lot of refactoring, some confusing names...), but many get fixed later on, and the refactoring part is actually pretty useful for intermediate learners like me. These videos are a glimpse into the mind and workflow of someone more experienced than me and that is valuable. It's hard to become good at coding by watching very rehearsed and edited videos where everything goes right the first time, when so much of actual coding is trying things, getting errors, finding and fixing them, trying again, getting new errors, etc. Also, without that style, these videos might not even exist. I make videos teaching biology and the amount of work it takes to make an entire video is so high it's hard to finish stuff. This iterative process that allows the creator to upload videos even if the entire project is not finished probably allows the videos to exist in the first place. Most importantly: they are free. This kind of depth and length is what you expect from university-level classes or udemy courses, and it is free here on TH-cam. Suddenly finding something like it is worth commenting, as I did.
This is such a great tutorial series/channel, especially that you don't take shortcuts but layer it logically piece by piece, taking the time to explain how it all fits together along with ideas on how it could be extended :) Exciting!
I've been looking for a way to make a runescape inventory/banking system and I LEGITIMATELY FIND a tutorial on how to make a runescape inventory/banking system. I have no words to describe how god damn fucking happy this makes me.
Best inventory tutorial series on the whole internet right now. Stick with it 'till the end and you'll learn quite a lot about game architecture. Then fiddle with it around a little bit and you can apply these concept to a lot of system, like shop system, skill system, etc.
One of the best tutorials I have seen on youtube. Showing what the end result will be, straight to the point and explained well. Exactly what I was looking for. Earned a sub.
you deserve more views man! this help me so much. After watching Brackeys, i still dont understand the grasp of inventory system but the way you explain it, i understand it right away!
Amazing tutorial... currently at part 2. It perfectly fits any kind of game you could possibly think of with only minor adjustments. And I like how the code and solutions are constantly changing just as in real-life coding. Thanks to that, it tells a lot about a developer's mindset and teaches different approaches. I was pretty much resigned after watching a few other lazy tutorials and now I'm actually ready to progress with other aspects of my game. 10/10 would (and will) watch again.
Brilliant, straight to the point and no nonsense. Thank you so much and keep up the great work dude. I greatly appreciate this video. Liked and subbed!
Great tutorial, I know I'm late to the party but instead of setting X_START/Y_START, you can set the anchor of the original prefabs & variant prefabs to top-right in the Inspector. Much faster to do, and then when you create additional variants from the original they will inherit the anchoring.
I'm only like eight minutes in and I swear to god this is the best unity tutorial on the internet. Not limited to the realm of inventory systems. Just, the best unity guide.
Thanks for the tutorial, it's very helpful for understanding how to use scriptable objects for various cases. Other people already mentioned using a UI grid for layout instead of manually setting where the inventory slot is displayed. Also, creating a method instead of copy-pasting commonly used code is better practice. I used a new method called AddDisplay() and moved the common lines in that one: private void AddDisplay(InventorySlot inv) { var obj = Instantiate(inv.item.prefab, Vector3.zero, Quaternion.identity, transform); obj.GetComponentInChildren().text = inv.amount.ToString("n0"); itemsDisplayed.Add(inv, obj); } Then you can replace those lines with this function as follows: public void CreateDisplay() { for (int i = 0; i < inventory.Container.Count; i++) { AddDisplay(inventory.Container[i]); } } public void UpdateDisplay() { for (int i = 0; i < inventory.Container.Count; i++) { if (itemsDisplayed.ContainsKey(inventory.Container[i])) { itemsDisplayed[inventory.Container[i]].GetComponentInChildren().text = inventory.Container[i].amount.ToString("n0"); } else { AddDisplay(inventory.Container[i]); } } }
Great video! I'm trying to make my own 2D game right now and couldn't figure out the inventory part. This has helped me so much and is way better than any other inventory tutorial I've found on TH-cam before. Everyone else's is so complicated and they do not explain the process as well as you do. Thank you!!!! Will definitely be watching the rest of this series. Even though it is much longer than the rest of similar series, it is worth it 100%.
Really helpful, thanks I've learned a lot, I watched code monkey's and implemented his, and I couldn't keep up with all the non-static references, I had to rework the whole thing. Best inventory tutorial I have found!
Thank you so much for this tutorial! Every other tutorial I could find was both very complicated and didn't have a very good result. But this it to the point, easy to understand and the result is so worth it!
You deserve more subscribers, this is amazing. I couldn't find anything I understood about an inventory system until I came across this. Thank you so much, you've helped so many people, what your doing is great! Keep it up
I like this tutorial a lot, it straight to the point ! Beside that, I have a tip for you all : I've struggle a bit upon the " Destroy(other.gameObject);" because "Destroy" is not immediate and thus, sometimes, my player picked up multiple time the same item before it was actually destroyed. So the simple fix is to add a boolean to your Items.cs script saying either or not it have been picked up or not and test it when picking it up : public void OnTriggerEnter2D(Collider2D collision) { var item = collision.GetComponent(); if (item && !item.haveBeenPickedUp) { inventory.AddItem(item.item, 1); item.haveBeenPickedUp = true; Destroy(collision.gameObject); } }
That tutorial was a rollercoaster ride. Glad I got through it with only a few mistakes and ended up with everything working by the end. Thanks for your hard work c:
For anyone who had issues with the position of the slot images/text, you might want to check out setting the anchor and anchored position instead of using the .position property. The anchored position is relative to the parent component (the inventory screen), instead of the overall position.
@@CodingWithUnity Not to be overly personal, but do you mind if I ask why? Also I hope my comment didn't come across as a slight against you, that was not my intentional all. Just expressing genuine grief that such a talented didact isn't around any more.
@@infernumex Just been bussy at work. The videos may not seem like it but they take a lonnggggggg time to edit, so its been hard trying to figure out how to make the videos and work at the same time. I appreciate the comments tho and do plan on making more videos, just no clue when
Hi, I'm new to your channel. I'm just as same as some people here, I have watched many tutorials about inventory system from Brackeys, Code Monkey ..etc... I'm not new to Unity, but I still cannot fully understand their logic and code. Yours is the most understandable I have met so far. Thank you for your neat explanation, although the grid layout can make the display code cleaner. You have my subscription.
Godot developer here. I've been struggling with creating an Inventory/Item/Equipment system for quite a while now and been desperately looking for tutorials. I finaly gave up searching for Godot specific tutorials and found yours and with just this first part it all finally starts making sense! Unity's ScriptableObjects are basically Godot's Custom Resources so everything is easily translatable to Godot. Thank you very much for your effort, you did a great job!
Cant thank you enough for this video. I have been searching for several days for something to explain how to create an inventory system with scriptable objects and you are the only person who has been able to explain this clearly. This is exactly what I needed! Thanks for this and I hope you continue to make content.
that's the best tutorial for implementing this system, but I had to use Grid layout group instead of doing it manually and it worked just fine, keep it up
I have to echo what some others have said and agree that your inventory system video is way easier to follow than some others. I've used this with a grid layout in Unity2D and it works perfectly. Thank you!
The cooking game I'm trying to make as my 2nd game ever was already turning into a gigantic mess and I was this close to give up, until I watched your video. THANK YOU SIR !!
getting this setup with my already existing ui might be annoying but the extensibility logic is so dope i really have no choice really amazing tutorial
You can for the most part strip the UI part out and remake that part and just use the backend Inventory logic, wouldn't be that much work because I'm only feeding info into the UI for the most part. (would have to figure out swapping items tho)
@@CodingWithUnity yea i think its easier when you go to the slot based system later so this should be decently easy to implement into mine. thanks again for these video buddy
So I finished this part of the tutorial. Since I wanted to have my item's icon display inside of my slot, I did a couple things differently. First, I had a slot image that I got from Brackeye's tutorial video, though the image was developed by Sebastian Lague. I made added a smaller image inside of the slot, as well as a textbox so I could display the amount. Then, I prefabbed that and placed is at the prefab gameObject. In my script, I wrote: obj.transform.GetChild(0).transform.GetComponent().sprite = inventory.Container[i].item.item_Icon; //This way, I am getting the child of my slot image, which is the main icon holder. obj.transform.GetChild(1).transform.GetComponent().text = inventory.Container[i].amount.ToString("n0"); //This way, I am getting the text component of the TMP text child.
This is the best so far in inventory system. On point and well explained on what each part does. One thing I thought about the inventory part that you showed, was that you could use it like chests or extra bags that you can equip like in Don't Starve. In this video I could understand and expand easily on, where on Code Monkey skips many parts and fast forwards too much where you end up spamming . and , to comprehend whats going on. Plus I hate writing something and then he erases it a few minutes later and writes new stuff like come on... I don't hate his tutorials, is just that those two things gets too irritating after a while.
There's a lot of valuable information here, thank you so much! I didn't really understand how inventory systems worked before but it makes a lot more sense now.
I love this! It's exactly what I was hoping to find. I was wondering why you made the "DisplayInventory" script instead of using the "Grid Layout" component that is available?
For those wanting to use this approach, this is the DisplayInventory code: public class DisplayInventory : MonoBehaviour { public InventoryObject inventory; Dictionary itemsDisplayed = new Dictionary(); private void Start() { CreateDisplay(); } private void Update() { UpdateDisplay(); } private void CreateDisplay() { for (int i = 0; i < inventory.Container.Count; i++) { var obj = Instantiate(inventory.Container[i].item.prefab, Vector3.zero, Quaternion.identity, transform); obj.GetComponentInChildren().text = inventory.Container[i].amount.ToString("n0"); itemsDisplayed.Add(inventory.Container[i], obj); } } public void UpdateDisplay() { for (int i = 0; i < inventory.Container.Count; i++) { if (itemsDisplayed.ContainsKey(inventory.Container[i])) { itemsDisplayed[inventory.Container[i]].GetComponentInChildren().text = inventory.Container[i].amount.ToString("n0"); } else { CreateDisplay(); } } } Remember to add the grid layout component in the InventoryScreen!
@@ignallacay I'm confused by Grid Layout, is that a script CWU made in a different video? or something inherent to Unity? ive got no errors but there are no sliders applicable to the script once ive applied it to the InventoryScreen
@@renzbolado153 Hey Renz, I just get to see the message, hope I got it on time. Grid Layout is a unity built in component. You'll find it easily by writing Grid Layout when adding a new component in the inspector. It will auto-arrange the child objects in the parent object with the Grid Layout component. You'll find the spacing, etc. variables in that component too. I also have a notification with another message about an error at the end of the code, but I'm not able to see the message, not sure if you deleted it
Thanks a ton for this tutorial had to search for several days to find one this good, found most others confusing and counter intuitive without the scriptable objects.
No slam on the instructor, but for those new to or learning C#, the correct term is "method" not "function" as in the video. Function is a term more generally used for reusable code blocks outside of a class. Whereas methods are contained within a class and ultimately establish the purpose of the class. Great video though, probably the best I have seen for setting up a simple inventory. I am looking forward to the entire series.
WOW YOU ARE SO UNDERRATED. Best tutorial that I have seen! It is so well explained. I am a beginner at coding, but you were so clear that I actually felt like I was learning + I was able to add some stuff that made it even better. Thank you so much!
Great info but definitely taught at a speed that he understands and a lot of different info at once. Definitely good information and I'll likely have to watch a few times to get everything if I don't want to just copy and paste his code and actually understand why he does things
Perfect video, i had no idea where to start with an inventory. This not only helped with me getting started but also helped so I can expand and customize this on my own.
nice video, watched it cuz of curiosity :) idea - you could shorten the function at 13:22 - you don't really have to use bool hasItem - you could just return from that for loop instead of breaking, that would not execute that Container.Add() function after it.... if you haven't returned from for loop (which will also end function), everything after it will be executed. IDK maybe it's dumb if you wanna improve that function later, just an idea :D
Just as a side note, instead of setting the location of the InventorySlot items, you can just use a GridLayout on the parent to configure where they are located. Just make the object with the GridLayout the parent of the InventorySlot item: var obj = Instantiate(slotPrefab, gridViewObject.transform, false);
Great video! I only flinched when i saw that the inventory ui is updated on every frame. I have not seen the rest of the videos yet, so if this is part of the others just ignore my comment, but if not, I would strongly suggest to use an event whenever the inventory changes to update the UI instead of updating it every frame. And putting the instantiation part in another method to not write and change it twice :P
I can't believe this doesn't have more views. Much more optimized than the leading videos and the pacing is near perfect, was very easy to follow along with. Excellent work man. Would love to see a base building tutorial if possible. Similar to Ark or Conan exiles?
I missed a few things here, so I had to combine some tutorials into one, but this one is by far the best and I used it as a learning base. But I have a note about the UpdateDisplay function. It shouldn't be in the update. It should only be called when picking up the item. Maybe it will be changed in next episodes, but I prefer to write it now.
Not a bad idea though you'll have to remember to add it to your dropitem, useitem, and exchanging when shopping/selling to vendors. Though it's less performant, for tutorial sake this way covers all of the above. I believe I ended up putting mine into a coroutine for now.
Great tutorial! one thing that could have been done easier is having unitys grid layout group do the item icon positioning rather than coding it from scratch.
I have used scriptable objects before but i have never really thought about using it in a multiplayer game. so this video has given me plenty of ideas. thanks mate :D
Awesome tutorial! I prefer a more visual way to set up the items in the UI (Like with an auto arranging grid) but the backend part is great stuff, amazing job!
This is a fantastic video. Best one I could find on TH-cam. Helped a lot. Thank you for sharing! Subscribing for sure and looking forward to more of your videos..
This is a great lesson! Really easy to follow, which makes the concepts easier to learn. I was stuck on this, and now I can't wait to move forward. You definitely earned a sub from me! Cheers!
love this video im so glad i found it.. its exactly what i wanted i just dident know how to put it into code.. thank you mate for the help in my game.. spent a week talking to wife trying to figure out the code then i found this video and it came together perfectly
Just so you know, you don't have to do all the math to set up your inventory in a grid. Just add in an empty game object under your panel, and add a Grid Layout component to it. Very easy to set up, and when the icons get instantiated, they immediately fall under the grid.
Excellent video. I watched a couple of other inventory videos and this one is by far the best. I just have 2 questions (and apologies if they have already been answered), but is there any reason you didn't opt for using the grid layout group? Is there also a specific reason why you don't just use the inventory container as the display source for the grid (and instead loaded the list into a dictionary first and then reference the dictionary to display items)?
Hey man, great tutorial. I was wondering, any reason for hardcoding the position of the object icons, instead of using something like the grid layout group component, for example?
Is there a way to set stack size for items? Cuz I don't want to stack swords and Guns. Thank you anyway for this great video I'm sure to use this in my game😊 also does this work in multiplayer? If this does probably need to do some tweaks still. Also subbed
Coding With Unity Definitely. I know theres few issues on serializing scriptable object for inventory system that have gameObjects. Will you be focusing on saving system down the line? Love the fact you enjoy Runescape.
Love the vid. Goes deeply into the code and showed me and my friend new ways of coding and this will fit perfectly in our new game and we well have great use of this in the future. Earned yaself a sub.
For those having trouble initializing the ScriptableObject. I had a problem when I started creating the FoodObject everything was fine but when I clicked the values reset. It was because I used the Awake function. When you click, the object is reset because unity calls the Reset() function. So if you want to fix overwriting values, use Reset() instead of Awake(). This worked for me.
THANK U SO MUCH 🎉❤ i was struggling for like 20 minutes using OnEnable and everything. This worked amazingly
If you've stumbled across this video randomly while trying to find a good tutorial on inventory system in unity, you've found what you need. It's a little complicated at first, and there are a lot of rewriting that will be done in the next videos, but it worth it in a long run and you actually learn something following these videos. So thanks for these videos, i hope you'll be able to make new videos again soon!
Does he eventually address the limitations of enums? Not that I am complaining, this is good information, but the enums is a limitation for creating a dynamic "item" system.
Just make sure you always pick the right names for the fields and never change them again, because renaming a field inside of a SO will cause you to lose all your data. That's one nasty thing they rarely mention about SO. You rename a field, and your data is permanently gone (unless you have a copy, of course). So you need to use the horribly clumsy way with [FormerlySerializedAs] attribute, which is reminiscent of programming in 1970'es. Instead of adding a rename option directly n the inspector.
I watched so many tutorials on this subject. The one by Brackeys, Sykoo, Code Monkey, Blackthornprod...
This one is by far the best inventory tutorial, and the only one that I fully understood.
thanks a lot! I really appreciate the kind words :)
also im glad you were able to understand it!
@@CodingWithUnity Same with me, Their tutorial were not bad but yours were exactly what I needed. Thanks for much for doing this.
same :D
Same :)
Honestly, same here! No hate to the others, but I was able to absorb this tutorial so much better.
This is hands down one of the best tutorials I've seen on this. Simple straight to the point organized (strangely rare in these Unity tutorials) and from what I've gathered so far extremely flexible. I don't even plan on making an RPG I wanted something for survival horror game and this is perfect.
I went into this extremely pessimistic. There are some very clunky and outdated tutorials on making Inventories and Interaction systems on youtube, but i had to pause this video despite being only 15 minutes in.
In these first 15 minutes alone I've learned more than the hours of clunky, messy outdated tutorials i've watched on the topic in the last few days. Thank you so much! Please keep doing what you're doing and making awesome tutorials! I feel by following along I'm actually learning so much more about unity's systems that I didn't know before or how to make use of it better. Thanks a lot! Instant sub!
Thanks alot for the feedback :) Its comments like this that makes the content worth putting out
You've been freed from tutorial purgatory! Congratulations!
Can you do this in 2D?
I finished the entire series a few weeks ago, and I came back to the first video, where my comment will have the most impact, to say, THIS TUTORIAL IS WORTH EVERY SECOND. My game received a huge upgrade from what I learned in 9 parts. if you've been searching for an inventory tutorial video this is THE ONE. (didn't mean to sound like a TV salesman, but i just got this thing to work with the gamepad, I no longer have to touch the mouse at all, and I'm through the roof right now)
That's awesome you got it working with a gamepad! Super cool
Also thanks a lot for the kind words
im making a 2d game will this inventory work for me?
@@kdawgfsho04 Yes Of course
You got it to work with a gamepad! Could you maybe tell me how you did it? I'm hoping to make an inventory that way cause I want my game to have a retro, played on an old Playstation, feel with no mouse.
@@mysteriz_madi it’s been a year so I don’t know exactly what I changed to be able to do that however I do remember that I had to copy most of the mouse code and rewrite it for use with the controller. I’m not exactly an expert with coding, so I think you’ll be able to figure it out, but as of now I’d have to looks through the scripts to find out what I changed.
I believe the majority of what I changed is in the userInterface script.
Start with changing the click to a button press, you’ll need to make another gameObject variable similar to the one that holds the item when selected with the mouse.
All I really did was copy all the input functions and refit them so that they can work with a controller.
Recently I managed to break something (after it was working for the better part of a year) and the mouse no longer works properly, which is why I’m not sharing the exact code.
Just chiming in to say this was the most in depth tutorial I have found on implementing this and it really helped me a ton. I really appreciate getting right to the meat of how to accomplish this, without spending a lot of time talking about useless bits.
Here 4 years after upload and this tutorial is still amazing. Thank you!
I'm half through this and this is the first Unity content creator I feel obligated to Subscribe to.
I'm so impressed at your delivery of information. I've done non stop tutorial/lesson surfing the past couple weeks and this one casually covers many of those I've seen with so much ease... and more. Half way, easy subscribe. I'm just hoping when I click your youtube page I see even more content!
Big thank you.
Thank you for this. As it turns out, what I needed to solve the issue I was stuck on in trying to make an inventory system from scratch myself was constructors, which I somehow didn't encounter or learn about until now. I don't think you really explained what that was in the video and at first I didn't understand it, but I looked up "constructor" in the C# docs and now it makes perfect sense and makes this whole process much, much easier.
Not only has this helped me plan out my inventory system, it's helped me solve another little headache I've been having which is how to store images in scriptable objects I need to serialize! Kicking myself I didn't think to just use prefabs... So simple!
Thank you!
its been 3 years but it helps me a lot on making inventory, thanks coding with unity, i wish you all the dreams that you had become true, thanks love you
I wish the same for you.
Glad the content has been helpful for you
I'll join the many comments that already praise this video and say that to me this was also one of the best videos at explaining inventories for beginners. Learnt everything I came here hoping to learn and more. And then I found out there are 7 more tutorials on the series covering everything about inventories. Amazing. I'm going to watch them now and will update the comment with my opinion when I finish.
Edit: Finished the series. Followed every step and everything worked. I learn A LOT more than I expected about unity and C# features and managed to implement the inventories I wanted in my game. I also did some adaptations and refactored some of the code so that the names made more sense to me. This is a deep tutorial and I had to watch some videos once without writing, then another time following along so that I could get the bigger picture before focusing on the details, but it was worth it. Almost everything gets improved in the next tutorials and many bugs that appear along the way are eventually fixed. The final system is perfectly usable in-game. The creator is charismatic and makes it entertaining to study. Overall, recommended.
Hope it helps you
Are you high? It sucks
@@daryll4645 Well, I'm on the last video of the series and I still think they are great. Maybe not for everyone, but they are exactly what I was looking for. I watched many videos by bigger youtubers but they didn't go into enough depth to allow me to add the features I wanted to add to my game. These ones did, and at the same time, they improved my understanding of unity features such as scriptable objects, abstract and static classes, inheritance, event triggers, and serialization.
They have their faults (a lot of refactoring, some confusing names...), but many get fixed later on, and the refactoring part is actually pretty useful for intermediate learners like me. These videos are a glimpse into the mind and workflow of someone more experienced than me and that is valuable. It's hard to become good at coding by watching very rehearsed and edited videos where everything goes right the first time, when so much of actual coding is trying things, getting errors, finding and fixing them, trying again, getting new errors, etc.
Also, without that style, these videos might not even exist. I make videos teaching biology and the amount of work it takes to make an entire video is so high it's hard to finish stuff. This iterative process that allows the creator to upload videos even if the entire project is not finished probably allows the videos to exist in the first place.
Most importantly: they are free. This kind of depth and length is what you expect from university-level classes or udemy courses, and it is free here on TH-cam. Suddenly finding something like it is worth commenting, as I did.
This is such a great tutorial series/channel, especially that you don't take shortcuts but layer it logically piece by piece, taking the time to explain how it all fits together along with ideas on how it could be extended :) Exciting!
Glad you enjoy it! :D
I've been looking for a way to make a runescape inventory/banking system and I LEGITIMATELY FIND a tutorial on how to make a runescape inventory/banking system.
I have no words to describe how god damn fucking happy this makes me.
Best inventory tutorial series on the whole internet right now. Stick with it 'till the end and you'll learn quite a lot about game architecture. Then fiddle with it around a little bit and you can apply these concept to a lot of system, like shop system, skill system, etc.
One of the best tutorials I have seen on youtube. Showing what the end result will be, straight to the point and explained well. Exactly what I was looking for. Earned a sub.
Please continue this series so many inventory tutorial don't go the distance and never get finishes.
you deserve more views man!
this help me so much. After watching Brackeys, i still dont understand the grasp of inventory system
but the way you explain it, i understand it right away!
This is exactly what I needed to get into developing a game. Thank you for your detailed explanation that is clear yet short and easy to digest.
Ok, this was really a good tutorial.
Complete, comprehensive, going strait to the point, and no BS.
Solid work!
Much appreciated!
TH-cam really didn't want me to find this video/series. But I finally stumbled upon it after weeks of looking for a inventory/item system video.
Amazing tutorial... currently at part 2. It perfectly fits any kind of game you could possibly think of with only minor adjustments. And I like how the code and solutions are constantly changing just as in real-life coding. Thanks to that, it tells a lot about a developer's mindset and teaches different approaches. I was pretty much resigned after watching a few other lazy tutorials and now I'm actually ready to progress with other aspects of my game. 10/10 would (and will) watch again.
Oh and now you do have the ads, gz!
Thats awesome to hear!
Brilliant, straight to the point and no nonsense. Thank you so much and keep up the great work dude. I greatly appreciate this video. Liked and subbed!
thanks a lot!
Oh my god this is amazing. This is the thing I needed to get over the hurdle that's stopped me so many times before. Thank you!
It is surprising how well you explain and from scratch to avoid getting lost.
Great tutorial, I know I'm late to the party but instead of setting X_START/Y_START, you can set the anchor of the original prefabs & variant prefabs to top-right in the Inspector. Much faster to do, and then when you create additional variants from the original they will inherit the anchoring.
Much more elegant than my solution would have been and you taught me about ScriptableObjects, great tutorial.
I'm only like eight minutes in and I swear to god this is the best unity tutorial on the internet.
Not limited to the realm of inventory systems. Just, the best unity guide.
we have the same last name :P
Thanks for the tutorial, it's very helpful for understanding how to use scriptable objects for various cases. Other people already mentioned using a UI grid for layout instead of manually setting where the inventory slot is displayed. Also, creating a method instead of copy-pasting commonly used code is better practice. I used a new method called AddDisplay() and moved the common lines in that one:
private void AddDisplay(InventorySlot inv)
{
var obj = Instantiate(inv.item.prefab, Vector3.zero, Quaternion.identity, transform);
obj.GetComponentInChildren().text = inv.amount.ToString("n0");
itemsDisplayed.Add(inv, obj);
}
Then you can replace those lines with this function as follows:
public void CreateDisplay()
{
for (int i = 0; i < inventory.Container.Count; i++)
{
AddDisplay(inventory.Container[i]);
}
}
public void UpdateDisplay()
{
for (int i = 0; i < inventory.Container.Count; i++)
{
if (itemsDisplayed.ContainsKey(inventory.Container[i]))
{
itemsDisplayed[inventory.Container[i]].GetComponentInChildren().text = inventory.Container[i].amount.ToString("n0");
}
else
{
AddDisplay(inventory.Container[i]);
}
}
}
Great video! I'm trying to make my own 2D game right now and couldn't figure out the inventory part. This has helped me so much and is way better than any other inventory tutorial I've found on TH-cam before. Everyone else's is so complicated and they do not explain the process as well as you do. Thank you!!!! Will definitely be watching the rest of this series. Even though it is much longer than the rest of similar series, it is worth it 100%.
Really helpful, thanks I've learned a lot, I watched code monkey's and implemented his, and I couldn't keep up with all the non-static references, I had to rework the whole thing. Best inventory tutorial I have found!
Thank you so much for this tutorial! Every other tutorial I could find was both very complicated and didn't have a very good result. But this it to the point, easy to understand and the result is so worth it!
Glad it helped you!
You deserve more subscribers, this is amazing. I couldn't find anything I understood about an inventory system until I came across this. Thank you so much, you've helped so many people, what your doing is great! Keep it up
I like this tutorial a lot, it straight to the point !
Beside that, I have a tip for you all : I've struggle a bit upon the " Destroy(other.gameObject);" because "Destroy" is not immediate and thus, sometimes, my player picked up multiple time the same item before it was actually destroyed. So the simple fix is to add a boolean to your Items.cs script saying either or not it have been picked up or not and test it when picking it up :
public void OnTriggerEnter2D(Collider2D collision) {
var item = collision.GetComponent();
if (item && !item.haveBeenPickedUp) {
inventory.AddItem(item.item, 1);
item.haveBeenPickedUp = true;
Destroy(collision.gameObject);
}
}
That tutorial was a rollercoaster ride. Glad I got through it with only a few mistakes and ended up with everything working by the end. Thanks for your hard work c:
I'm glad you managed to get it working!! Great work c:
For anyone who had issues with the position of the slot images/text, you might want to check out setting the anchor and anchored position instead of using the .position property. The anchored position is relative to the parent component (the inventory screen), instead of the overall position.
This is such a solid tutorial. It's a real shame the creator doesn't make videos any more, this channel has a wealth of knowledge.
it is a shame
@@CodingWithUnity Not to be overly personal, but do you mind if I ask why? Also I hope my comment didn't come across as a slight against you, that was not my intentional all. Just expressing genuine grief that such a talented didact isn't around any more.
@@infernumex Just been bussy at work. The videos may not seem like it but they take a lonnggggggg time to edit, so its been hard trying to figure out how to make the videos and work at the same time. I appreciate the comments tho and do plan on making more videos, just no clue when
@@CodingWithUnity I completely understand, making videos is a huge amount of work. Hope to see your return at some point!
Hi, I'm new to your channel. I'm just as same as some people here, I have watched many tutorials about inventory system from Brackeys, Code Monkey ..etc... I'm not new to Unity, but I still cannot fully understand their logic and code. Yours is the most understandable I have met so far. Thank you for your neat explanation, although the grid layout can make the display code cleaner. You have my subscription.
First you make bones, then a Monkfish.
The RuneScape is strong with this one.
XDDD yee
First inventory system tutorial I watched that actually seems practical. Thanks!
Great to hear!
Godot developer here.
I've been struggling with creating an Inventory/Item/Equipment system for quite a while now and been desperately looking for tutorials. I finaly gave up searching for Godot specific tutorials and found yours and with just this first part it all finally starts making sense!
Unity's ScriptableObjects are basically Godot's Custom Resources so everything is easily translatable to Godot.
Thank you very much for your effort, you did a great job!
Thats really awesome! Glad it helped
Those RS references tho xD
Scriptable objects are so powerful, I keep finding new uses for them. Great tutorial!
Glad you like them!
Cant thank you enough for this video. I have been searching for several days for something to explain how to create an inventory system with scriptable objects and you are the only person who has been able to explain this clearly. This is exactly what I needed! Thanks for this and I hope you continue to make content.
Really appreciate the comment!
This tutorial is exactly what I was looking for to create my inventory system. Thank you!
I love that part in the end you said : this is a pretty " BASIC " way :)))))
that's the best tutorial for implementing this system, but I had to use Grid layout group instead of doing it manually and it worked just fine, keep it up
I have to echo what some others have said and agree that your inventory system video is way easier to follow than some others. I've used this with a grid layout in Unity2D and it works perfectly. Thank you!
The cooking game I'm trying to make as my 2nd game ever was already turning into a gigantic mess and I was this close to give up, until I watched your video. THANK YOU SIR !!
Im glad I helped make your project a bit easier
getting this setup with my already existing ui might be annoying but the extensibility logic is so dope i really have no choice really amazing tutorial
You can for the most part strip the UI part out and remake that part and just use the backend Inventory logic, wouldn't be that much work because I'm only feeding info into the UI for the most part. (would have to figure out swapping items tho)
@@CodingWithUnity yea i think its easier when you go to the slot based system later so this should be decently easy to implement into mine. thanks again for these video buddy
So I finished this part of the tutorial. Since I wanted to have my item's icon display inside of my slot, I did a couple things differently. First, I had a slot image that I got from Brackeye's tutorial video, though the image was developed by Sebastian Lague. I made added a smaller image inside of the slot, as well as a textbox so I could display the amount. Then, I prefabbed that and placed is at the prefab gameObject. In my script, I wrote:
obj.transform.GetChild(0).transform.GetComponent().sprite = inventory.Container[i].item.item_Icon;
//This way, I am getting the child of my slot image, which is the main icon holder.
obj.transform.GetChild(1).transform.GetComponent().text = inventory.Container[i].amount.ToString("n0");
//This way, I am getting the text component of the TMP text child.
This is the best so far in inventory system. On point and well explained on what each part does. One thing I thought about the inventory part that you showed, was that you could use it like chests or extra bags that you can equip like in Don't Starve.
In this video I could understand and expand easily on, where on Code Monkey skips many parts and fast forwards too much where you end up spamming . and , to comprehend whats going on.
Plus I hate writing something and then he erases it a few minutes later and writes new stuff like come on...
I don't hate his tutorials, is just that those two things gets too irritating after a while.
A F*cking Legendary Tutorial, you did in 5 minutes what Sykoo couldn't achieve in an Hour...
Far and away the best inventory tut I have watched. And this is Vid 1!! Thank you for putting this together!
There's a lot of valuable information here, thank you so much! I didn't really understand how inventory systems worked before but it makes a lot more sense now.
I love this! It's exactly what I was hoping to find. I was wondering why you made the "DisplayInventory" script instead of using the "Grid Layout" component that is available?
didnt think about the grid layout component when i made it :)
For those wanting to use this approach, this is the DisplayInventory code:
public class DisplayInventory : MonoBehaviour
{
public InventoryObject inventory;
Dictionary itemsDisplayed = new Dictionary();
private void Start()
{
CreateDisplay();
}
private void Update()
{
UpdateDisplay();
}
private void CreateDisplay()
{
for (int i = 0; i < inventory.Container.Count; i++)
{
var obj = Instantiate(inventory.Container[i].item.prefab, Vector3.zero, Quaternion.identity, transform);
obj.GetComponentInChildren().text = inventory.Container[i].amount.ToString("n0");
itemsDisplayed.Add(inventory.Container[i], obj);
}
}
public void UpdateDisplay()
{
for (int i = 0; i < inventory.Container.Count; i++)
{
if (itemsDisplayed.ContainsKey(inventory.Container[i]))
{
itemsDisplayed[inventory.Container[i]].GetComponentInChildren().text = inventory.Container[i].amount.ToString("n0");
}
else
{
CreateDisplay();
}
}
}
Remember to add the grid layout component in the InventoryScreen!
@@ignallacay I'm confused by Grid Layout, is that a script CWU made in a different video? or something inherent to Unity? ive got no errors but there are no sliders applicable to the script once ive applied it to the InventoryScreen
@@renzbolado153 Hey Renz, I just get to see the message, hope I got it on time. Grid Layout is a unity built in component. You'll find it easily by writing Grid Layout when adding a new component in the inspector. It will auto-arrange the child objects in the parent object with the Grid Layout component. You'll find the spacing, etc. variables in that component too.
I also have a notification with another message about an error at the end of the code, but I'm not able to see the message, not sure if you deleted it
@@ignallacay does the grid layout component version work with drag and drop?
Thanks a ton for this tutorial had to search for several days to find one this good, found most others confusing and counter intuitive without the scriptable objects.
No slam on the instructor, but for those new to or learning C#, the correct term is "method" not "function" as in the video. Function is a term more generally used for reusable code blocks outside of a class. Whereas methods are contained within a class and ultimately establish the purpose of the class. Great video though, probably the best I have seen for setting up a simple inventory. I am looking forward to the entire series.
I make this mistake quite often and is great to point out!
WOW YOU ARE SO UNDERRATED. Best tutorial that I have seen! It is so well explained. I am a beginner at coding, but you were so clear that I actually felt like I was learning + I was able to add some stuff that made it even better. Thank you so much!
It starts super complicated but I can see it making entire game creation whole lot easier.
Great info but definitely taught at a speed that he understands and a lot of different info at once. Definitely good information and I'll likely have to watch a few times to get everything if I don't want to just copy and paste his code and actually understand why he does things
Perfect video, i had no idea where to start with an inventory. This not only helped with me getting started but also helped so I can expand and customize this on my own.
Oh my god. Watching this and realizing you can do whole lot of systems using this way of game development. Thank you.
Your welcome, you can check out the open game project unity is doing also. They use SO for their architecture in a lot of places as well
nice video, watched it cuz of curiosity :) idea - you could shorten the function at 13:22 - you don't really have to use bool hasItem - you could just return from that for loop instead of breaking, that would not execute that Container.Add() function after it.... if you haven't returned from for loop (which will also end function), everything after it will be executed. IDK maybe it's dumb if you wanna improve that function later, just an idea :D
Awesome! Glad it caught your curiosity!
Also thats a great idea! Ill most likely do that!
@@CodingWithUnity yo I always like to find ways for making the code as short and quick as possible, that helps out with readibility later on a bit :D
Just as a side note, instead of setting the location of the InventorySlot items, you can just use a GridLayout on the parent to configure where they are located. Just make the object with the GridLayout the parent of the InventorySlot item: var obj = Instantiate(slotPrefab, gridViewObject.transform, false);
excellent intro to inventory systems… i like the clearness …i am writing my own and this has pointed me to a better workflow. many thx
Great video! I only flinched when i saw that the inventory ui is updated on every frame.
I have not seen the rest of the videos yet, so if this is part of the others just ignore my comment, but if not, I would strongly suggest to use an event whenever the inventory changes to update the UI instead of updating it every frame.
And putting the instantiation part in another method to not write and change it twice :P
I do make that change eventually
This tutorial was awesome, I learned a lot watching this. This is precisely the inventory system I wanted for my side project game.
By far the best tutorial. First video is better than anything else out there. Can't wait to watch full series
I can't believe this doesn't have more views. Much more optimized than the leading videos and the pacing is near perfect, was very easy to follow along with. Excellent work man. Would love to see a base building tutorial if possible. Similar to Ark or Conan exiles?
subscribed, and put the bell on!
thanks a lot! And a base building series would be cool to do, but no promises on if i will be able too
i love you so much. every other inventory tutorial on youtube is no where near as good as this
I missed a few things here, so I had to combine some tutorials into one, but this one is by far the best and I used it as a learning base. But I have a note about the UpdateDisplay function. It shouldn't be in the update. It should only be called when picking up the item. Maybe it will be changed in next episodes, but I prefer to write it now.
Not a bad idea though you'll have to remember to add it to your dropitem, useitem, and exchanging when shopping/selling to vendors. Though it's less performant, for tutorial sake this way covers all of the above. I believe I ended up putting mine into a coroutine for now.
Can't believe how much this video accomplishes in 30 minutes. Thank you.
Glad it was helpful!
Dude great stuff, the other tutorials out there weren't as concise and well put together as yours.
Glad you like it!
This a very clear, precise, and intuitive implementation of scriptable objects! Thank you
no problem!
Thank you as well!
Awesome tutorial, I've never thought using scriptable objects this way. I'll watch it again tomorrow because there is a lot of content here to learn
This tutorials really help me, I have developed and use your tutorials and apply this to all of my elements!
I just finished This tutorial and it works exactly like it should. thanks for the info.
You're welcome!
Great tutorial! one thing that could have been done easier is having unitys grid layout group do the item icon positioning rather than coding it from scratch.
I have used scriptable objects before but i have never really thought about using it in a multiplayer game. so this video has given me plenty of ideas. thanks mate :D
Thank you for the video. Really straight forward to follow and understand. And being British, gotta' love that accent. The way you say bones hahaha
Awesome tutorial! I prefer a more visual way to set up the items in the UI (Like with an auto arranging grid) but the backend part is great stuff, amazing job!
This is a fantastic video. Best one I could find on TH-cam. Helped a lot. Thank you for sharing! Subscribing for sure and looking forward to more of your videos..
This is a great lesson! Really easy to follow, which makes the concepts easier to learn. I was stuck on this, and now I can't wait to move forward. You definitely earned a sub from me! Cheers!
This is the only way an inventory system should be implemented in my opinion. I guess it depends on the game, but either way. A+
This series looks great it's worth an Abo :D keep going
This is absolutely fantastic, love the whole series. You are a true hero, thanks a thousand million
love this video im so glad i found it.. its exactly what i wanted i just dident know how to put it into code.. thank you mate for the help in my game.. spent a week talking to wife trying to figure out the code then i found this video and it came together perfectly
7:01 lmfaoo it’s own unique name, unique description, etc.
Just so you know, you don't have to do all the math to set up your inventory in a grid. Just add in an empty game object under your panel, and add a Grid Layout component to it. Very easy to set up, and when the icons get instantiated, they immediately fall under the grid.
Oh yeah, forgot about that :)
@@CodingWithUnity makes it SO much easier
Haha deff alot less code!
Ill try to point out that that is doable ina future video
Excellent video. I watched a couple of other inventory videos and this one is by far the best. I just have 2 questions (and apologies if they have already been answered), but is there any reason you didn't opt for using the grid layout group? Is there also a specific reason why you don't just use the inventory container as the display source for the grid (and instead loaded the list into a dictionary first and then reference the dictionary to display items)?
Instantly saved the whole playlist for future reference. Great stuff.
Awesome, thank you!
Phenomenal tutorial. optimal pacing and explanation for beginners. Thank you!
Finally, an inventory system tutorial for programmers. Thank you!
Enjoy!
You are very dedicated
Hey man, great tutorial. I was wondering, any reason for hardcoding the position of the object icons, instead of using something like the grid layout group component, for example?
Is there a way to set stack size for items? Cuz I don't want to stack swords and Guns. Thank you anyway for this great video I'm sure to use this in my game😊 also does this work in multiplayer? If this does probably need to do some tweaks still.
Also subbed
Okay, I didn’t know you will post this early. I am so happy! Thanks for this!
No problem! Hope you like it
Coding With Unity Definitely. I know theres few issues on serializing scriptable object for inventory system that have gameObjects. Will you be focusing on saving system down the line? Love the fact you enjoy Runescape.
Yes ill make a video specifically showing how to serialize, save and load the scriptable objects
Coding With Unity Best youtuber right now. No bullshit haha ❤️
That's good~ I have been searching for the way how to make my game more flexible while managing so many items in one character
Love the vid. Goes deeply into the code and showed me and my friend new ways of coding and this will fit perfectly in our new game and we well have great use of this in the future. Earned yaself a sub.
Big thanks for making this. It taught me enough to make my own unique inventory system!
That's wonderful to hear!