First of all, thank you BMo, this is an incredibly elegant and flexible system that you demonstrated. Thanks for the added delegate example, that helped me a heck of a lot to finally understand delegates (still not 100%). Posting this part for anyone else that might come across this tutorial and had similar trouble as I did understanding a few parts. I had a lot of trouble understanding the difference between the usage of the "inventory" list and the "itemDictionary" dictionary in the Inventory script. First of all, how you implement either of these entirely depends on how you will use the data from your inventory system later on. One thing that I got hung up on is that I thought these 2 variables were somehow linked together. They are not, they are independent. If you look in the inspector, you will only see the list. Even if you were to make the dictionary public, or serialize it, you wouldn't see it because Unity does not display dictionaries in the inspector. I believe BMo goes on in the next tutorial to use these two variables differently which is why he created both of them. I was so confused because to me personally I would have just looped through the dictionary keys instead of creating the list at all.
@dibaterman2 жыл бұрын
So for people as dumb as I am here is how Events are working in this very simple illustration provided in the video: Starts with > OnTriggerEnter > Looks for if the other has ICollectible if it does it fires off Collect > Collect fires off the Event inside of the collected item > Your Inventory was listening for this and fires off Add. What I don't see is a way to specific an inventory. So if you have npcs with their own inventory, this would technically give all the npcs inventory the same item regardless of who set off the event? I consider it a big deal for me if I can read the code well enough to understand that-that is likely the case, but I'll know for sure when I test it after finishing the video.
@sak59866 ай бұрын
First off, great tutorial, loved it. The only thing I'm wondering is how to implement a Use/remove functionallity with this. I've already tried event based, Raycast, buttons etc, but nothing has worked so far, so was just wondering. Anyway, great video BMo, hope to see even more in the future
@joshw52422 жыл бұрын
I love your content! You're helping out with stuff that I have questions with and show it in a clear and concise way!
@mandamoon91492 жыл бұрын
My happy inventory gets BIG when I see a new BMO video 😊
@ayeitskhi7549 Жыл бұрын
Easy to follow along and packed with everything you need to get started another great video !
@BMoDev Жыл бұрын
Thanks 👍
@phambaoha1702 жыл бұрын
very intuitive and easy to understand
@KaanErayAKAY2 жыл бұрын
Great tutorial, great explanation. I hope your channel grows more.
@GalipCanKARAARSLAN7 ай бұрын
Just wonderfullll, love it and first time watching your videos, now gonna subscribe and open notifs...
@GalipCanKARAARSLAN7 ай бұрын
And please keep creating more videos/contents for game development
@psy_gamer2 жыл бұрын
Very good video! The system is quite simple and convenient.
@Glori4n2 жыл бұрын
Thank you for the great insight!
@khaelus_dev Жыл бұрын
Amazing tutorial. Thank you so much.
@Purgious2 жыл бұрын
Doing God's work with your videos man!
@stefansigurdsson21462 жыл бұрын
Nice and clear tutorial!
@puntalic2 жыл бұрын
Would by nice if the code alse accounted for a maximum amount of inventory space, like slots, or max stacks. Not hard to implement, but thought that part was missing. Maybe something for a follow up.
@frostymug31232 жыл бұрын
Best Unity tutorial series I've come across props!
@Stompin402 жыл бұрын
Another banger
@kaisonlee712 жыл бұрын
Nice video man!! Can you make a crafting system using Scriptable object for your next content?
@umapessoa60512 жыл бұрын
Hi, thanks for the video, isnt easier to do a "public static event Action OnGemCollected" instead of a delegate with a parameter?
@BMoDev2 жыл бұрын
You can this was an excuse to explain delegates which i get asked about constantly
@umapessoa60512 жыл бұрын
@@BMoDev oh alright, thanks !
@eileeng24922 жыл бұрын
Interesting topic Thank you
@darknside2 жыл бұрын
Nice content, thx man, i view from Russia
@farsquadfilmsltd.59972 жыл бұрын
is there a way to do an inventory check? (i.e. you need a specific key to open a door.)
@molecular_master2 жыл бұрын
Ah man, why haven't you made this series earlier? This is a really clean and readable method compared to mine which is like spaghetti with meatballs :D
@sevazakharenko81762 жыл бұрын
Great video, very helpful! One thing I am currently struggling with in designing my game is being able to save the game with a complex inventory system such as this. Would you be able to point me towards a tutorial you may have surrounding this topic? I have a solution to this that seems rather tedious, but it seems like there are very few data types you can save using the "System.Serializable" tag. But I imagine there must be some way of easily converting scriptable objects or something into simple data types and then saving those to a binary file. Either way, any help would be awesome, thank you!
@adygombos44692 жыл бұрын
At 11:00 I think Action does the same thing.
@anmaavr8315 Жыл бұрын
I love your content! Thank you for the awesome video! Is it possible to reference the scene to the Scriptable object instead of the item icon?
@andrueanderson86372 жыл бұрын
Quick question about ICollectable + Gem as a class: Isn't "Gem" a game object? Making a MonoBehaviour called "Gem" seems to imply that the game object "is a" gem (inheritance) vs "has a" gem (composition). On the surface this seems to go against the notion of composition over inheritance. What am I missing?
@dibaterman2 жыл бұрын
Gem is attached to a gameObject thus making it a GameObject.. I think the disconnect here is that Gem is also and SO and Gem is also a list object. Similar data exists at the same time. In short the Gem on the screen, is not the Gem in the inventory, it's just a representation of data. The Gem class if I recall correctly is there to be picked up, so that technically is an ItemPickUp script that he named GemScript. Because it's a monobehavior you can do all kinds of things with it too, for example, since you are using SO you can set the items icon sprite and then on the pickup script tell the SpriteRenderer to use the icon as its sprite.
@PandoraBox06 Жыл бұрын
For whoever want a mix between item stackable and not here is the thing i did to achieve that (not sure if its the best but it work) In ITEMDATA add the following bool after your other variable : public bool isStackable; in INVENTORY above everything in using add : using System.Linq; and in INVENTORY still change the method Add(ItemData itemData) to : public void Add(ItemSO itemData) { var thisItem = inventory.FirstOrDefault(x => x.itemData == itemData); if (thisItem != null && thisItem.itemData == itemData && thisItem.itemData.stackable) { thisItem.AddToStack(); OnInventoryChange?.Invoke(inventory); } else { InventoryItem newItem = new(itemData); inventory.Add(newItem); OnInventoryChange?.Invoke(inventory); } } and for Remove method : public void Remove(ItemSO itemData) { var thisItem = inventory.FirstOrDefault(x => x.itemData == itemData); if (thisItem != null && thisItem.itemData == itemData) { thisItem.RemoveFromStack(); if(thisItem.stackSize == 0) { inventory.Remove(thisItem); } OnInventoryChange?.Invoke(inventory); } }
@suicune20012 жыл бұрын
Thanks! This was awesome. :)
@export_dev91642 жыл бұрын
Wouldnt it be better to have a general collectable pickup event so you wouldnt have to subscribe to the pickup event of every single collectable item you have in your game?
@AsaFalyRayyan4 ай бұрын
Great tutorial! But what if I have more than 1000 collectible items(gem, gold, silver, so on), do I have to create all script for each item called gem.cs gold.cs silver.cs, or is there a better way?
@hipppiejesus45672 жыл бұрын
when did he script blueGemData ?
@disruptive_innovator2 жыл бұрын
Thanks for the tutorial. Why use a List and a Dictionary at the same time? Maybe just use the Dictionary?
@BMoDev2 жыл бұрын
The List is useful for things like ordering/sorting your inventory, but again everything can be adapted to what you need for your situation. If it doesn't offer you any utility, scrap it.
@disruptive_innovator2 жыл бұрын
@@BMoDev Makes sense. Thanks.
@Xu0mi_11 ай бұрын
Hi! And how to make gui inventory in which the Icon and the Amount of the item will be recorded?
@DarkkneZPanda Жыл бұрын
it seems subscribing to the events for the audio and text scripts from the previous video has errors because its a different delegate. Any way to fix this?
@samserious54832 жыл бұрын
Very clean, thanx
@Corummo Жыл бұрын
With this kind of approach, every single collectible item has a separate class with an inner event to subscribe to. So if I add a new item to my game, I have to create a separate class with its own new event to subscribe. And what if my game has to manage 1000 collectibles? This method doesn't take any advantage from the ScriptableObject real purpose, i.e. decoupling data from the source code. The ideal implementation would be limited just to the creation of a new ScriptableObject, leaving the core code untouched. That's the purpose of ScriptableObjects, as clearly demonstrated by a very old Brackey's video on the subject.
@TimelordSnowy2 жыл бұрын
how to do this without events? Im not picking up items. But this is like exactly how I want my inv to function. But I keep getting a nullreference when i try to add items
@bidjo6662 жыл бұрын
Hello, what about saves? How to save Scriptable Objects in a build.
@novachi092 жыл бұрын
Don’t you think it would be better to just stick to a dictionary and use the List of values instead of the inventory list? It would make it a single source of truth for the whole inventory. I might be wrong tho since I’m a beginner when it comes to C# and Unity but for me it would make sense.
@mr.pillow2 жыл бұрын
can u do 2-player controls?
@employerslave Жыл бұрын
for example I have a key and I use it on the door how can I delete it from inventory?
@Gears2Game Жыл бұрын
Get reference to the Inventory and on your on use key logic, call the Remove(itemdata) - your key itemData.
@PrototypeMarl2 жыл бұрын
Either this doesn't work with Unity 2021.3.8f1 or I'm just doing something wrong
@keithwilliams1921 Жыл бұрын
it worked for me
@butchinator1988 Жыл бұрын
Am I being an idiot? Where are the items being stored? Im not reaching AddNewItem as the inventory is already populated but I cant physically see the list. Is it stored somewhere in Unitys memory?
@blinken772 жыл бұрын
Hi! Great tutorial but i am trying to make it so that if you try to pick up two swords of the same type you can only pick up one. Can you help me with this if it is possible?
@heribertosalais46782 жыл бұрын
What is the meaning of the operator "?." on 0:45 in the line "OnGemCollected?.Invoke();" ?
@Worrior3142 жыл бұрын
It is the short hand writing for: if (OnGemCollected != null) { OnGemCollected.Invoke(); } if he doesn’t check for null and nothing is subscribed to the OnGemCollected event, it would throw an error message.
@mysterycube98912 жыл бұрын
hey man thank you for helping beginners. I have a question how to separate 2 game object with same script? i have 2 object and both of them have enemy script and on Death method i Instantiate an effect with event Action but when i kill one of them the effect plays for both of them even though one of them is still alive.
@firebiscuitgaming76242 жыл бұрын
hard to say without looking at your code but my intuition is the bug might be in the code that decides which enemy to target for the death event.
@SeverskiyS2 жыл бұрын
maybe you use static events?
@darkman2372 жыл бұрын
What if you wanted separate types of items like a weapon, an armor, something consumable like a potion?
@Community-Compute2 жыл бұрын
Add an enum to the ItemData Scriptable Object that stores an item type. That's a simple way.
@chritsfootballs2 жыл бұрын
You can also make an abstract itemData class then make different scriptable objects with different fields
@darkman2372 жыл бұрын
@@chritsfootballs That's a cool idea! Could you give an example?
@chritsfootballs2 жыл бұрын
@@darkman237 coding with unity has a video on it in his part one. int eh scriptable object inventory System
@darkman2372 жыл бұрын
@@chritsfootballs Thanks!
@godzillakingkongvenom2 жыл бұрын
🔥🔥🔥🥦🎮
@anonym78654 Жыл бұрын
Is it Working on 3d game
@officiallambs2 жыл бұрын
Epic!
@heyreefes2 жыл бұрын
Naisu
@dkordy Жыл бұрын
Unbelievable, but all you developers. Everyone, literally. Something always goes wrong in the tutorial, and I struggle with that something for days afterwards. For example, here in this Inventory tutorial everything is perfect and you explained everything perfectly, but in the end when I created Inventory, and in Update() succeeded on some key when I press to hide it and display it Inventory - when I pick up the Item, of course it is not displayed in Inventory because for example the Inventory -panel is inactive at the time. So, in order for it to be displayed when I pick up an Item, I have to have the Inventory Panel Active (visible) all the time, otherwise it won't process - Slot wont be Upadated. Do you understand me? No Updates on the Inventory slot when the Inventory Panel is not active. And now I have to waste days and days until I find the answer to how to do it. You could have just mentioned - If you don't want the Inventory panel to be always visible, then you should do this and that in order for the slot to be updated. And of course you didn't say that, you left it out, and that's what everyone, literally everyone does, always leaves something out. Not everyone wants their inventory panel to be visible all the time... How i now to resolve that problem? Can you tell me?
@dkordy Жыл бұрын
PLEASE!!!!
@verenabecker2724 Жыл бұрын
This is one of the most entitled posts I've seen in a long time. Dude, there are a billion different small issues that will crop up for different people implementing this in different circumstances and maybe using different versions of Unity. It makes you seem incredibly ungrateful if you're this cranky about a free tutorial not catering to your exact needs. No one here owes you their time and expertise.
@dkordy2 ай бұрын
@@verenabecker2724 So, did I ask you for something? After all, I didn't demand anything from anyone, I just asked for help. If it's none of your business, why bother answering anything? Unless you're being paid to shove yourself where you don't belong? I'm not being ungrateful or grumpy, I'm just stating my observation of the tutorial. And I exposed that to whoever made the tutorial. But I'm sure my post doesn't concern you. No one asked for your opinion on my post, so if you don't want to help, ignore it. Or are you crawling up the "professor's" a** to score some points? I don't understand, why are you stuffing yourself when no one asked you anything?
@JAKEAVALON-rg8xm2 ай бұрын
I just used easy method GameObject flase and true😂
@urpwnned Жыл бұрын
i have 0 clue what the hell "item" is referencing
@SeverskiyS2 жыл бұрын
isnt static events a horrible idea?
@Reaxgrim2 жыл бұрын
nm fixed it :D lol
@mike_b102 жыл бұрын
🙏
@fatihemirhangungor82972 жыл бұрын
What's your equipment ? Like keyboard ?
@BMoDev2 жыл бұрын
I have a custom mechanical keyboard, but brown switches