Unity Course – Inventory system, perfect for RPG, Roguelike and Stardew Valley like games!

preview_player
Показать описание
In this course long Unity tutorial we will explore how to create an inventory system. You will be able to create multiple items quickly, pick up items, drop items, generate inventory ui and many more. During the whole tutorial I will do my best to share as much knowledge, skills, tips and tricks as I can. This is definitely not ‘complete beginner’ tutorial, however I did my best to explain as much details as I can so you can follow around.

In case you have any questions or anything is unclear please feel free to join our discord.

If you would like to show me some support: 

If you are looking for a great community:

00:00:00 What we will be creating
00:01:25 Architecture Overview
00:06:46 Where to find the code
00:07:03 Item Definition
00:13:10 Item Stack
00:19:00 Game Item Automation
00:27:50 Item Detector
00:33:09 Inventory Slot
00:41:28 Adjusting Inventory Size
00:47:00 Find Slot & Can Accept Item
00:56:42 Adding Items
01:09:10 Inventory UI - Scene Setup
01:16:19 Inventory UI - Script
01:22:52 Inventory UI - Showing state on init
01:35:00 Inventory UI - Reacting to the event
01:36:45 Has Item & Remove
01:52:12 Inventory UI - Active Indicator
02:01:03 Throwing Items
02:19:41 Final Test
02:20:16 Final Words
Рекомендации по теме
Комментарии
Автор

Note about the PrefabUtility - it comes from the UnityEditor package and it is editor-only utility intended for editor tools, which means you can't use it in the game code, as the project will not build any files that use editor namespace.
It is fine for our Inventory UI script as long as you wrap it (the method where we use it, and probably the "using UnityEditor" line too) in # if UNITY_EDITOR preprocessor block.
As for the object spawner thingie near the end that executes in runtime - it's a no go. We have to use normal instantiate there, but we didn't gain anything from using InstantiatePrefab there anyway

_vicot
Автор

Hello Fantastic People!

IMPORTANT: Condition in 00:54:02 inside FindSlot should be "slot.Item == item && (item.IsStackable || !onlyStackable)" !!

IMPORTANT: In the video I use the PrefabUtility, use regular Instantiate instead! Please check @Vicot’s comment where he explains the issue! Thank you Vicot, you are a star. I am learning so much from you!

This is the largest tutorial I have done until now. I decided to call it 'Course' because it covers a lot of things - much more than the Inventory System. I did my best to share as much skills and knowledge as I can and give you as many tips and tricks as I could remember. I hope you have fun watching that and that the inventory system will actually be useful for you. Love you!

If you would like to show me some support:

If you are looking for a great community:

PitiITNet
Автор

Your explanation is very easy to understand. Can you make a complete video about a system that includes item pickup, inventory, and crafting? Thank you very much! 😊

NgọcHiếuTrần-tg
Автор

you are just a god, my friend and I could not find a normal guide, thank you (we went to your channel there are still a lot of useful guides, many thanks again)

waiter_pro
Автор

Great video!!! I did have the same problem you had with destroying items from a context menu, but figured it out eventually. When trying to delete prefabs, what you need to do is to destroy the gameobject, and not the rectTransform, because it will have dependecies like SpriteRenderers in children that cause the error you were getting when trying. Ill post an example in the discord!

AlChmi_MvP
Автор

Thank you for sharing your knowledge for free. Your tutorials are great and easy to follow. This video easily could've been part of a Udemy/skillshare course. Watching the first few minutes inspired me to donate to your Patreon. Thank you for all that you do.

gameartdevelopment
Автор

Incredible man! I thought that was some kind of udemy course or smth! But you made it for free and its 2 hours! Thanks for your effort mate. I'm appreciated.

TheKrckeR
Автор

I really love it to see how your channel is growing and your tutorials are getting better and better❤️

sim-card
Автор

Exactly what I was looking for: Tutorials on game systems! Please do more, maybe a questing system next? :)

epiphanyatnight
Автор

Finally finished watching. Overall nice tut, great job! One additional tip: you could create slots class that is innumerable. It would hide some complexity of handling collection. You could also make some short video about this little "pattern", because not many ppl know about it.

MarekNijaki
Автор

This was the best inventroy tutorial I have seen on youtube! Explaining and showing every step and line of code, which many other tutorials skip. Don't worry about the length, on the contrary it is a blessing for anyone who really wants to learn. Hope your channel will skyrocket soon, because with such content it's a sin to have only 2.5k subscribers :)

sandrok
Автор

The most complete tutorial I've ever seen on youtube, you could certainly sell this tutorial, if you made a combo of classes including this tutorial, a crafting system and a building system in a 2D game, I guarantee you would have one great number of sales! I would be the first to buy!
Obs: When it came to the Input configuration part it was very confusing and I couldn't understand it, it would be nice to do it in a simpler way, it would help beginner programmers a lot!

garnios
Автор

Very nice tut for begginers like me. And no, it was not too long. The way you explain most things were great. Lots of "aha, I finally get that" moments. My only small issue, was when you were clicking in the editor, I had to replay a few times to catch just what was happening. Thank you for this, and I will be checking out any other videos you have/are doing.
edit: patreon says you no longer take customers....

geneanglen
Автор

Finally found the time to follow along and start implementing it in a project. The system feels great and works like a charm :) I didn't even get any stupid bugs since following along was really easy. I'm super happy with this system and will make sure to copy it over into my toolbox for future games ❤

ChristinaCreatesGames
Автор

Thanks for sharing your wisdom with us. 😇🙏🏻 You got a subscriber. 😀👍🏻

Aye_Sid
Автор

This was awesome! Just wish it showed more to do with using the selected items in the inventory, like an axe or sword!

TheGreatProphecy
Автор

Another nice video. Maybe it is just me, but when I've created inventories, I almost never use Linq, IMO List's Find/Exists along with a delegate you supply to it is usually enough. Also, it would be interesting see how you would go about creating an inventory with items that have some unique values, like wear/use count or such.

ss
Автор

Yo, you could use field attributes in place of NumberOfItems. It would make code little bit simpler

MarekNijaki
Автор

35:00 you can use tuple instead class InventorySlotStateChangedArgs, like 【public event EventHandler<(ItemStack, bool)> StatChanged;】So In Function NotifyStatChange is 【StatChanged?.Invoke(this, (itemStack, _isActive));】
Finally 1:27:54 Function OnStateChanged(object sender, (ItemStack, bool) e) {UpdateViewState(e.Item1, e.Item2); }

circlezero
Автор

It would be nice to see something like based on the type of item you have selected your player does different things. Like how it is in stardew. If you have a buildable you are in building mode, if you have a seed you can plant it or now, if you are infront of a machine you place it.

This is the stuff i struggle with when it comes to items.

Also if i have say spells in my game, which pretty much have the same functionality of items, but arent picked up, they are learnt and you have a seperate inventory. Like how does this all fit togethe

its always easy doing one system, but then all these questions come up and my brain implodes

chargnmalazr