Creating The Backend | Unity Inventory System Tutorial - Part 1

Поделиться
HTML-код
  • Опубликовано: 11 янв 2025

Комментарии •

  • @StanTheMovie
    @StanTheMovie Год назад +7

    I know I'm like a year late to the party, but this is so helpful. I've watched a hundred of these tutorials and this is the first one I've found that actually explains the logic behind everything. It's much better than "Create an inventory system in 20 minutes!" where you just copy what they're doing in the video with no understanding of why at the end of it. Thanks so much for putting this up.

  • @DanPos
    @DanPos  3 года назад +34

    Since filming this series I have got saving and loading working of the inventory system so if you'd like to see that let me know!

    • @inkofthedragon
      @inkofthedragon 2 года назад

      Do you have the save/load system posted already? Also do you have a video showing the equipping of, for example, a helmet? Like when you select the helmet in inventory, the specific helmet shows up on the player. And then unequip, removes the helmet model? Thanks

    • @DanPos
      @DanPos  2 года назад

      @@inkofthedragon Save loading is up yes, no item equipping has been done

    • @inkofthedragon
      @inkofthedragon 2 года назад

      @@DanPos ok cool. Is that something you plan on incorporating?

  • @ecosmile4212
    @ecosmile4212 2 года назад +3

    I have watched a lot of video tutorials in Russian and in English (about 20 in total). this video turned out to be the only one that clearly explains the theory of the inventory system. thank you very much to the author for the work done!

  • @StixxyTape
    @StixxyTape 2 года назад +3

    This is a great tutorial, and the fact that you're putting something of this quality and efficiency out for free on youtube is amazing. Thanks so much for this great tutorial!

  • @skourge891
    @skourge891 2 года назад +1

    I had followed another inventory tutorial a while ago that ended up not having the chest system implemented in it, thought id start a new inventory system from scratch again and this series was exactly what I needed. Thanks for providing this gem of a tutorial ;)

  • @thenetimp
    @thenetimp Год назад +1

    in MaxStackSize you don't need the else statement, if it's true it'll return true, otherwise it continues, and you can just return false by default. Could also consider making the item slot have a max stack size and not just the item. Since you may not want to allow stack sizes greater than X in the hot bar, for example a weap0n may be stackable in your pocket, but not in your hotbar.

  • @michaeltherandomperson9652
    @michaeltherandomperson9652 6 месяцев назад

    I really like the tutorial so far. I have tried to make the system by myself and I am looking at how others implemented this. I learnt a lot just from these few videos.

  • @HB-wk6zj
    @HB-wk6zj 2 года назад

    I've understood everything so far! I hope the next parts will be as easy to comprehend, I was a bit scared at first because Inventory Systems looked really complicated.. but I start to think that it's not that much ! Thanks for these series!!

    • @DanPos
      @DanPos  2 года назад +1

      You can do it!

  • @thebarsambahrami
    @thebarsambahrami 6 месяцев назад

    Beat explaining ever, you got a loyal follower

  • @JoaquinHurtado-zb7gp
    @JoaquinHurtado-zb7gp 20 дней назад

    I thought I knew enough C# until I saw this guy.

  • @timurnikolaev1438
    @timurnikolaev1438 2 года назад +1

    hi started watching this playlist, so far so good, thanks!

    • @DanPos
      @DanPos  2 года назад

      Glad you enjoy it!

  • @bigt5481
    @bigt5481 2 года назад

    Very helpful tutorial and greatly appreciated Dan

    • @DanPos
      @DanPos  2 года назад

      Glad it was helpful!

  • @timurnikolaev1438
    @timurnikolaev1438 2 года назад

    really like the quality of your code

  • @littlealienthings
    @littlealienthings Год назад

    Awesome video! Works well!

    • @DanPos
      @DanPos  Год назад

      Glad it helped!

  • @tehuster
    @tehuster 2 года назад

    Nice video dude! You've got a new sub.

    • @DanPos
      @DanPos  2 года назад

      Thanks for the sub!

  • @mixedtrigenito
    @mixedtrigenito 2 года назад

    this is incredibly educational

    • @DanPos
      @DanPos  2 года назад

      Glad you enjoyed it!

  • @windbox1060
    @windbox1060 3 года назад +1

    It seems wonderful for now. I wonder what features are you gonna add?

    • @DanPos
      @DanPos  3 года назад +3

      Other than everything shown in episode 0, if there's enough interest I've since got saving and loading working to save not just the inventory, but also which items on the ground have been collected.

  • @mosasaurus2211
    @mosasaurus2211 3 года назад +1

    Someone hire this guy to minecraft

    • @DanPos
      @DanPos  3 года назад +1

      Cheers!

  • @DTTK
    @DTTK 2 года назад

    Learned a lot from your vid, thx

    • @DanPos
      @DanPos  2 года назад

      My pleasure!

  • @duriniskawaiiiiiiiiiiiiiii7593
    @duriniskawaiiiiiiiiiiiiiii7593 2 года назад +5

    hey why i done the same thing you do but on InventoryHolder script
    i cant expand "Inventory System"

    • @Fuzzietomato1
      @Fuzzietomato1 2 года назад

      I cant see the item system in the serialized fields either.
      EDIT - Figured it out. Make sure you added [System.Serializable] and [Serialized Field] in InventorySystem.cs as well.

  • @Daniel_Hochmuth
    @Daniel_Hochmuth Год назад

    Awesome tutorial. Quick question though - around 17:36 I'm a bit confused why there's ItemData on line 33 (with capital I) and itemData (with lowercase i) on line 40. I know it's initialized at the top but I don't get that line either. I'm fairly new to C# and this concept is not very clear to me. Thanks!

    • @dragonsagesummoner6071
      @dragonsagesummoner6071 Год назад

      To answer your question it has to the with the privacy of the fields. The capital is public and points to the private fields that is lower case. This is to allow access security to the private field from other scripts.

  • @min_2187
    @min_2187 Год назад +2

    So I'm having 1 issue and would appreciate it anyone could help me, but when i put the Inventory Holder script on the player it doesn't display the Inventory System list, it just shows None(Inventory System)
    I would appreciate any answers,
    Thanks in advance!

    • @dronkarian
      @dronkarian Год назад

      I had one problem where the Inventory system didnt show up at all. I had forgot to add [System.Serializable] at top of the Inventory system script. Maybe not the same problem you had.

  • @KamekoTsuruga
    @KamekoTsuruga Год назад +1

    any time i try to pass something back using => unity just tells me its a read only file.

  • @AyyyyyyyyyLmao
    @AyyyyyyyyyLmao Год назад

    Hi there, I'm currently looking for the best way to handle an inventory system that is built to handle a lot of items.
    I'm building a great interactive and scalable UI in the UI toolkit but I haven't quite decided on the best way to physically store this data.
    I am against the idea of using a scriptable object for every item created, as there will be a lot of items in the game and I'm worried about the long-term effects this will have on performance.
    I would love to hear your thoughts on these quick questions!
    A) Is this system in the tutorial is designed for mass item storage / handling?
    B) Can you point me in the direction of a system that is designed for mass item storage / handling?

  • @AbdulazizAlmawash
    @AbdulazizAlmawash 2 года назад

    Great tutorial! Thank you.
    Question, why did you choose to make 'serialized' fields then have other public variables to access those while we can just make the public ones and deal with them? thanks.

    • @DanPos
      @DanPos  2 года назад

      SerializeField only allows you set them in the inspector. Public would let you set them from other scripts which isn't good coding practice as you don't want one script directly changing a variable on another script

  • @daveplay69
    @daveplay69 2 года назад +2

    a do the same and i dont have any errors but it wont pick up or destroy

    • @RileyMacfarlane-cg3or
      @RileyMacfarlane-cg3or Год назад

      did you ever find a fix for this??

    • @daveplay69
      @daveplay69 11 месяцев назад

      nope@@RileyMacfarlane-cg3or

    • @milosmilovanovic658
      @milosmilovanovic658 3 месяца назад

      i also had this problem. he is coding this for a 3d game. if you are making a 2d game you should use OnTriggerEnter2D(Collider2D other) and also use 2d colliders. this was the problem in my script. i spent a whole day figuring this out

  • @thebulletkin8393
    @thebulletkin8393 9 месяцев назад

    Been working on my own inventory system and have hit a roadblock that’s prevented any progress for the last month, wondered if you had any idea.
    Essentially, I’ve got an inventory that consists of slots like yours, but the type of item in the slot can be any one of three different types. These items can’t derive from each other because they are completely different items, but that means I’ve had constant errors when I try to get the item in slots and assign them. In general, when dealing with an inventory that can hold completely different types of item, how might I go about keeping it working?

    • @DanPos
      @DanPos  9 месяцев назад

      They can't derive from each other but do they derive from a base class? Or do they derive directly from MonoBehaviour?
      If they just inherit from MonoBehavior then make a new base Item class, which your other items inherit from, and then have the inventory store a reference to the base item class?

  • @user-bj9vk1wl6q
    @user-bj9vk1wl6q 2 года назад

    thank you so much

    • @DanPos
      @DanPos  2 года назад

      No problem

  • @TropicalCyc
    @TropicalCyc 2 года назад

    Im completely stuck, I cant expand Inventory system on Inventory holder at all.

  • @boomerslayer1
    @boomerslayer1 2 года назад +1

    ""You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all"" item disappears, not adding items to InventoryHolder and getting this error? And I don't see stack size

    • @DanPos
      @DanPos  2 года назад

      As the error says, you're using the new keyword on a monobehaviour class, make sure you don't inherit from it in the classes where I remove it.
      Feel free to join the discord linked in the description and I'll try to help you some more, it's easier than on RUclips

    • @boomerslayer1
      @boomerslayer1 2 года назад

      @@DanPos I'm using unity 2021 version, does the version matter?

  • @memecraftgamer8311
    @memecraftgamer8311 2 года назад

    When I hit run it takes multiple minutes to run, then when it does the slots are not added, anyone know why this is.

  • @ThatGuyNamedBender
    @ThatGuyNamedBender 3 года назад

    Out of curiosity will you be using the legacy UI system in Unity or the UI Toolkit?

    • @DanPos
      @DanPos  3 года назад

      This will be using the legacy/built in UI - I haven't actually looked into the UI toolkit yet

  • @SofyCatYT
    @SofyCatYT 2 года назад

    anyplans to make the hotbar more functional? :D

    • @DanPos
      @DanPos  2 года назад

      Yes I have some Patreon exclusive bonus videos planned and this is one of them, along with equipment slots and controller support :)

    • @SofyCatYT
      @SofyCatYT 2 года назад

      @@DanPos anyplans to release it on the channal or is it patron only?

    • @DanPos
      @DanPos  2 года назад

      @@SofyCatYT not currently but maybe in the distant future

    • @SofyCatYT
      @SofyCatYT 2 года назад

      @@DanPos I respect that :D I might become a patron once it come on there

  • @laserbean00001
    @laserbean00001 2 года назад

    why do you do
    public InventoryItemData ItemData => itemData;???
    It's literally the same thing as making the itemData a public variable. Unless there's something I'm missing.

    • @DanPos
      @DanPos  2 года назад

      if you make a variable public, it can be accessed from any script but also be changed from any script. Doing public InventoryItemData ItemData => itemData means it can be accessed from other scripts but can't be changed by them. Further reading: www.w3schools.com/cs/cs_properties.php

    • @laserbean00001
      @laserbean00001 2 года назад

      @@DanPos or you can do public type var_name {get;}

    • @DanPos
      @DanPos  2 года назад +2

      @@laserbean00001 yeah but then you can't see it in the inspector that way

    • @laserbean00001
      @laserbean00001 2 года назад

      @@DanPos true true.

    • @laserbean00001
      @laserbean00001 2 года назад

      @@DanPos I would still use a public variable that "gets" the private serialized variable instead of a lambda function. i guess...

  • @gigani...4363
    @gigani...4363 Год назад

    aggghhghh why does it want to convert int into InventoryItemData???

  • @cateye2k7
    @cateye2k7 Год назад

    nice tutorial but unfortunately doesnt work for me. I copy as you type without any deviation from it and get about 10 lines of error with error codes CS1014 CS1525 CS1002 and CS1513 popping up several times in InventorySlot.cs :(