I have only recently started to use unity and start programming, so I am not quite sure how I should deal with this issue. I want to make an inventory system, I know how to do this regarding the canvas and images etc, however the issue I am not sure with is how do I make something happen after clicking an object in the inventory. As an example, if I have an image of a medpack displayed, how would I go from clicking that image to actually having it effect my player.
Hi,
There are many many inventory tutorials, code snippets and Github repos out there.
Did you try to search for “Unity inventory tutorial” or “Unity inventory Github”?
I did but was sort of wanting to try and do it myself, I think I got so far on my own with setting up the look of it, but just not how to handle the actual interaction part. Guess I could take a look at an inventory tutorial and just get ideas
Inventories (and shop systems) are fairly tricky hairy beasts. They contain elements of:
- a database of items that you can possess
- a database of the items you actually possess
- persistence of this information to storage between game runs
- presentation of the inventory to the user (may have to scale and grow)
- interaction with items in the inventory
- interaction with the world to get items in and out
- dependence on asset definition (images, etc.) for presentation
Just the design choices of an inventory system can have a lot of complicating confounding issues, such as:
- can you have multiple items? Is there a limit?
- are those items shown individually or do they stack?
- are coins / gems stacked but other stuff isn’t stacked?
- do items have detailed data shown (durability, rarity, damage, etc.)?
- can users combine items to make new items?
- can users substantially modify items with other things like spells, gems, etc.?
- does a worn-out item (shovel) become something else (like a stick) when the item wears out?
- etc.
Your best bet is probably to write down exactly what you want feature-wise. It may be useful to get very familiar with an existing game so you have an actual example of each feature in action.
Once you have decided a baseline design, fully work through two or three different inventory tutorials on Youtube, perhaps even for the game example you have chosen above.
Or… do like I like to do: just jump in and make it up as you go. It is SOFT-ware after all… evolve it as you go!
Breaking down a large problem such as inventory:
“Combining a bunch of stuff into one line always feels satisfying, but it’s always a PITA to debug.” - Star Manta on the Unity3D forums