My first attempt at making an Inventory System!

Поделиться
HTML-код
  • Опубликовано: 20 сен 2024
  • I've been working on an inventory for 1 Month now, and inventories are definitely not what I expected... Let me explain.
    ❗️Check out this next video!❗️
    • Learning Game Dev in 1...
    ❗️Join this channel to get access to perks:❗️
    / @floky
    ❗️Discord❗️
    / discord
    -Are you starting your journey in game dev? Are you looking to make some friends with the same interests as you to motivate and help each other out? Well... my discord is empty for now but I'll gladly be your company if you still decide to join! :D
    My name is Floky and I make Game Dev videos!
    #DevLog #GameDevelopment #IndieDev #GameDev #UnrealEngine #inventorysystem #GameInventories #Floky

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

  • @MyGameDevPal
    @MyGameDevPal 2 года назад +29

    I laughed so hard when you told me you thought items were shrunk, oh floky 😂😅🥶

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

      Looking back at this... It makes me laugh as well
      But from the people I asked most of them either thought the same thing or thought the items were teleported to a inventory "room" were they waited to be teleported back XD

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

    I wish this video was available a year ago. It has the best explanation of what an Inventory is. Meanwhile it took me watching countless hours of tutorials on how to make an Inventory system before I even figured out that an Inventory is just an array. A few months later and I finally figured out array structs and then nesting structs within each other so you can have say... a bag that can hold items like a box that can hold items. Now I'm down the rabbit hole.

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

      Hahaha, yeah... It's quite difficult in the beginning 😂

  • @andreww4751
    @andreww4751 Месяц назад +1

    "Man this game has such a dope inventory " Yes I have many times

  • @lucahaverty667
    @lucahaverty667 2 года назад +12

    A list would be useful for this instead of an array because you can add and remove elements as you wish instead of defining a set length

    • @betatester03
      @betatester03 2 месяца назад

      You can add and remove things from an array, but it takes a bit more work up front. Arrays store their contents in continuous memory, so iteration is much faster. Also, if you don't know what the storage capacity of an inventory is ahead of time to define the array size, then, you're probably not designing your implementation very well.

  • @emberwulfz6948
    @emberwulfz6948 2 года назад +8

    Scriptable Objects in Unity can be very good for doing an inventory system - Not sure for unreal, but if you research it a bit they may have something similar. I hope this is true and can help you!

  • @Terandium
    @Terandium 2 года назад +7

    Some advice (bit late, but here goes)
    Use an array with ur own item object. Should solve all ur problems.
    And fun fact arrays start at 0, not 1.

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

      I did that in the next devlog but thank you very much for the input
      Yeah... I messed up when writing the script... My brain doesn't like stuff that starts at 0 😂

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

      @@Floky I've seen the 2nd devlog but it was like a week ago haha

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

    The way I'd do it is with a dictionary, a set of key-value pairs. Like:
    {
    "0": {
    "item": "Apple",
    "quantity": 15
    },
    "1": {
    Etc
    }
    }
    Or they way I'm actually doing it now, is to set up an object with some properties for any item (these would be the properties from the item list you showed), an object with the properties for a slot (item object and quantity) and an object with the properties for an inventory (an array of slot objects). Then create a separate display and pull the information from the previous objects assigned to the player. It's easy to save and it's really modular.

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

      Yeah, the second option is how I ended up doing it later on 😁👍

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

      @@Floky Nice, keep it up. I've since watched the rest on this series and I can't wait to see what you do next

  • @Otacsom
    @Otacsom Год назад +3

    In theory, you could have used a struct array, to save some time. Unreal doesn't like structs that are super complex, but having it store the item name, quanitity, spoilage/durability (since it's a survival game), etc, and then using the struct as the variable type for the array is the approach I went with for my current project.

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

      Yeah, I made that change in the next devlog! Thanks for the input 😁👍

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

    Dude I forgot how frustrating Skyrim’s inventory was. I can’t image a modern day game pulling that nonsense

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

      Yeah, that was literally just Bethesda being lazy...
      But hey, there was an inventory mod that was amazing 😂

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

    Nice video! Figured I would drop a little bit of Unreal lore :)
    It seems like you would already be using a structure as you showed the item information displayed in a data table. However, that would by far be the easiest way to manage an inventory. In the same way that you use a structure to create a data table, you can just store an array of that structure. This means there will be some overlap of context-based information such as a current/max stack count, or the actor class for it's in-hand counter-part, but doing this save a lot of headaches overall, and you can have as many structures as you want with matching information.

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

      Thank you very much for your reply, I appreciate everyone guiding me in the comments!
      I have already made that change in my next video thanks to other comments that said the same thing you just explained!
      But I'm very gratefull for all the help you guys are giving me! :D

  • @kevinbittner5069
    @kevinbittner5069 6 месяцев назад +1

    I dont use a map for my inventories but you could do it and still avoid the problems you mentioned. Datawise there will be one big stack. Hudwise you can still segment them by the max stack size. For refernece I use a struct.

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

      Yeah I opted away from using maps and also started using structs! It's way more convenient! :D
      Thanks for the input 👍

    • @kevinbittner5069
      @kevinbittner5069 5 месяцев назад

      @@Floky It get's even better when you use structs and data assets together it will change your life.

  • @awesomegamedev
    @awesomegamedev 2 года назад +7

    The "problem" seems quite made up. Need to store two pieces of information? =>
    a) Just make two arrays:) or
    b) Make array of structs (struct { int count; Item item; }) or
    c) Embed 'count' information in the item itself
    "Empty item" is a proper solution. Array indeed needs to contain something.
    In modern languages that support algebraic data types, that would be some special 'None' case.
    But C++/C# don't have that, so you could either use 'null' or "empty item".
    Minecraft inventory is completely horrible. There is nothing cool in micro-management. Auto-sort button is really missing.

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

      As someone figuring it all out I don't feel like I made up the problem, I do indeed see that I could have simply used a second array, but I didn't... This video was simply me showing my journey of discovering the world of game dev and finding out how games work behind the screen... And ofc the solution I found to a problem I encountered :P
      This wasn't supposed to be a tutorial or a course... Simply a video about a dude struggling to do basic things 😂

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

      Ohh, and Thank you for the solution listed! I live I learn 😜

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

      @@Floky If it's any consolation I can totally get how you fell into this trap and I have 10+ years experience.
      Definitely look into storing structs or game objects in your array instead of primatives (strings, numbers, etc).
      If you want to be able to drop a whole stack into the world and have it stay as a stack I'd recommend game objects but I'm not super familiar with unity to know if there would be any negative side-effects from doing that (like maybe you have to toggle their visability rather than remove them from the world? Depends on how unity does garbage collection).

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

      @@slBrelaz So... I've experimented with storing structs in arrays, but I have to say I'm confused on how your supposed to find specific items in the arrays since the structs don't really have any "searchable" terms... any documentation/tutorial you could send me towards?

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

      @@Floky Iterate through the array and find the one with a property that matches what you're looking for, like
      InventoryArray[Index].Name == "Apple"

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

    I thought making a inventory system is easy but after researching about Minecraft inventory system you made me realise that I'm absolutely wrong 😂

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

      You and me both XD

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

    yo pretty nice video...i like how you manage to make all ur videos more than 5 minutes whereas most of the creators now a days make 3 minute video (including me)...and you still manage to get more than 1k views on evry video, epic bro!

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

      Well I try to do stuff slightly differently, create my own style of videos instead of trying to just copy what works
      But thanks for the compliments 😁

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

    Ggs in the vids floky. Keep them up

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

      Thanks! Will do! 😁

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

    I do plan to learn about making an Inventory system soon, I thought it was simple, but I guess nothing in game development is simple.

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

    is that a new diablo gaming chair!?!?!?

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

      Hahaha, I just stole my gf chair because mine was making some weird noises 😅
      I don't like gaming chairs, I prefer a good office chair 😬

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

      @@Floky diablo is the only good gaming chairs!!

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

      @@Mr_Haster it is a good chair! BUT I prefere not having leather ony chair since you sweat more in leather chairs, I prefere having chairs with this weird net material because you always feel nice and fresh 😁👌

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

    As always Floky, i love your devlogs, they are super funny and even informative. I told you many times before, keep at it, it looks like this is actually your thing :)
    Now onto the recommendation to make your inventory a bit less intricate.
    I think a better approach would be to have 1 array that can store objects of type "Item" which is simply a custom C++ Class you create. Each "Item" is a C++ Class that contains all the information such as 2D image, 3D-Object and what not. That way you only need one array but you can store different types of "Item"s in the array. It's difficult to describe in words, but making a custom class for Items is the best way imo. I think knowing about maps and such is good, but this looks all way too overcomplicated :D You can even store the type of an item such as "apple" or "wood" or "potion" in the class "Item". You also store the amount of how often you got the item in your inventory. Let's say you have 20 apples on the first slot, now you add the functionality to split the stack when you right-click the item, that way you can also have 2 apple stacks with 10 apples. The array doesn't care what type of item it is, it only cares that it is of type "Item", but it doesn't matter if it is a banana, apple, wood, glass or whatever you want to store in such "Item" class. You can also use inheritance to extend the class "item". Sadly explaining this in a youtube comment is too much of a limit. But imagine you have a class "Item". This class contains the name of the item, a picture and the 3d model. But let's say you want the item to be an apple which you can eat and which then would up your HP or so. Implementing that in the class "Item" would be bad, because you don't to be able to eat a sword :D So, what you would do is you extend the class "Item" by using Inheritance and that new class, that extends the class "Item" will then implement the funcionality of eating. You would call the class something like "consumable" and in there you have the function "eat()". I hope i explained it well enough, if you want i can elaborate on it more (if i find the time for it :D). Edit: Oh and for the last part, yes, having an "empty" object is actually quite normal i would say. I mean atleast thats how i would do it ^^
    As always, as i said in the beginning, i love your videos and i hope to see much more glowing shit of you :D

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

      Thanks man! I actually did change my inventory to something similar to what you said, I used a struct 😁

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

      @@Floky Ye i watched the latest video after this and noticed :D Awesome man, i like how you are progressing! Keep it up!

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

    Inventory without having a Radioactive Poop should is like using a PC without having Internet.

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

      This guy gets it! 😉

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

    damn i'm in this video lol. Nice explanations of arrays and stuff

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

      Hahaha, thanks!

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

    why is the index of the apple 1, isnt it supposed to be 0 ?

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

      You are totally right 😅

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

    Wow dude I had know idea it was so complicated cool

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

    Just make Slot class that stores the item count and item name. Then use the slot class in a list or array. if your using indexes to keep track of inv. slots then you don't need maps.
    Maps are more used for liking names to other info, like what you said at the start - an item is just a name of the item that links to the items info, like a map. "apple": "apple info stuff"

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

    I like your videos I am subscribe and liked I don't know why you have only 1k 😭😭

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

      Thanks! and Welcome :D

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

    Great vid! :)

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

      Thanks! 😁

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

    What microphone is that?

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

      rode podmic :)

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

    Your way of doing things isn't very object oriented. I would make ItemStack class that has property item - an object of class Item (composition over inheritance) and integer quantity, inventory would be array of ItemStack objects.
    Edit: nevermind, I see you did that with structs in next video.

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

      Yeah I'm learning a lot through my comments 😂
      In the future I want to step away a bit from blueprints and try to double down a c++, I think it would help a lot with improving my "Coding logic"
      But thanks a lot for your input, comments like these really help me improve! 👍

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

    bruh why the frick did you use minecraft bedrock footage oh my god

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

      Hahaha
      I'm so sorry!! I simply quickly downloaded MC and just jumped into it and Bedrock was the quickest download... I would never play it tho!
      Man... you make me feel bad now XD

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

      the "oh my god" just hits hard hahaha

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

      @@Floky lol it's ok, i was half-joking

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

    yeah right he's gonna use 2d arrays right? RIGHT?

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

      😅

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

      So, after your comment I made some research on 2D arrays... and to my big surprise, 2D arrays do not exist in Unreal no matter if you work in Blueprints on in C++ directly... What a weird thing XD

  • @这不是你的问题
    @这不是你的问题 Год назад +2

    On

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

    first

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

      Nice :O

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

    🥗

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

      Bot3x wanna play some new world?

  • @samuelboadas8333
    @samuelboadas8333 8 месяцев назад +1

    Bruh doesnt know anything about Databases or simple programming

    • @Floky
      @Floky  4 месяца назад

      I was getting started xD
      It wasn't a tutorial, it was just me showing what I've done, and yes, looking back at this, I wasn't very good yet 🤣

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

    You wouldn't make a map. You could either have two arrays, one for the objects and one for the count (i.e., your second map is also an array) or you just put both the inventory item and count in the same array slot using a struct (or whatever the equivalent is). You can also put the grid location or whatever in there. These are all problems an experienced programmer would find solutions to in minutes.

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

      Yeah, that Makes sense!

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

      it’s unnecessary to mention the obvious fact that experienced programmers are better than beginners, does more harm than good in this context