Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Old School RPG Inventory List

Discussion in 'Scripting' started by ckamarga, Dec 18, 2022.

  1. ckamarga

    ckamarga

    Joined:
    Aug 31, 2013
    Posts:
    15
    Hi everyone,

    I'm looking for a tutorial on how to create an RPG inventory list. Let me clarify though, I'm talking about old school inventories where it's a scrollable window with a list of names of each item and you have a cursor pointing to an item that you can move up or down.

    Moving up or down will scroll through the list (if you move beyond what is shown of course) and you press a button to select it.

    Whenever I try to find an inventory tutorial, I keep getting ones that are grid based or where you use a mouse to instantly select an item, or it's a list of buttons. The one I'm looking for is like the inventory in Final Fantasy 7 (except only 1 column).

    I've attached an example from an JRPG called Breath of Fire 3 that is basically what I'm aiming for:

    bof3_inventory.PNG

    Anyway, any help would be appreciated.

    Thanks in advance!
     
  2. NotLunch

    NotLunch

    Joined:
    Oct 12, 2021
    Posts:
    30
    Well, Unity has the scrolling thing already done for you, it called the Scroll View in UI. You can put buttons in the scroll View which can do events in a script that controls UI. I think that is what you are looking for. A GUI you can scroll up and down on and click on and interact with. Here is a good tutorial from Backeys if you need information on how to do this in more detail.
    , A tutorial for the buttons I recommend is
    which is also Brackeys.
     
  3. ckamarga

    ckamarga

    Joined:
    Aug 31, 2013
    Posts:
    15
    Hi, thanks for the response.

    I looked at Brackeys but his inventory system is not really what I'm looking for.

    I'm not familiar with Scroll View but then again I've never used it before so I will look into that as a start at least. Thanks :)

    If anyone else knows of any other tutorials (doesn't have to be a video as well), please don't hesitate to post them.
     
  4. AnimalMan

    AnimalMan

    Joined:
    Apr 1, 2018
    Posts:
    1,164
    Take a look at unities layout components, they save a tonne of work. And I have done the work. And trust me, the unity vertical and Horizontal layout component will give you the results you want with minimal coding.
    https://docs.unity3d.com/2018.3/Documentation/Manual/script-VerticalLayoutGroup.html
    it is trivialised by simply inserting an object into a hierarchy list. Perhaps there is a downside to them that the user could improve on but I am yet to find!
    https://docs.unity3d.com/2020.1/Doc...ild,the spacing between them is added as well.
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,713
    Tutorials are not about finding exactly the thing you want, usually.

    Don't get hung up on the shape or structure of any one thing in a particular tutorial.

    Instead, understand the parts: the storage of the data, the presentation of the data, and interacting with the data.

    Here's some more notes to help you break down the parts so you can assemble them as you like:

    These things (inventories, shop systems, character customization, etc) are fairly tricky hairy beasts, definitely deep in advanced coding territory.

    They contain elements of:

    - a database of items that you may possibly possess / equip
    - a database of the items that you actually possess / equip currently
    - perhaps another database of your "storage" area at home base?
    - persistence of this information to storage between game runs
    - presentation of the inventory to the user (may have to scale and grow, overlay parts, clothing, etc)
    - interaction with items in the inventory or on the character or in the home base storage area
    - 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?
    - if there is an item limit, what is it? Total count? Weight? Size? Something else?
    - 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? How? Limits? Results? Messages of success/failure?
    - can users substantially modify items with other things like spells, gems, sockets, etc.?
    - does a worn-out item (shovel) become something else (like a stick) when the item wears out fully?
    - 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.

    Breaking down a large problem such as inventory:

    https://forum.unity.com/threads/weapon-inventory-and-how-to-script-weapons.1046236/#post-6769558

    If you want to see most of the steps involved, make a "micro inventory" in your game, something whereby the player can have (or not have) a single item, and display that item in the UI, and let the user select that item and do things with it (take, drop, use, wear, eat, sell, buy, etc.).

    Everything you learn doing that "micro inventory" of one item will apply when you have any larger more complex inventory, and it will give you a feel for what you are dealing with.
     
  6. ckamarga

    ckamarga

    Joined:
    Aug 31, 2013
    Posts:
    15
    Thanks for the additional responses.

    @AnimalMan - I checked out Vertical Layout Group and it's indeed very handy! Thanks for the links as well.

    @Kurt-Dekker - That's a fair point yeah and I understand I'm getting into some advanced coding territory but hey, what better way to learn right? But I agree with you. I'll break down what I exactly need and take it one step at a time before finding tutorials that will help me with the various components. Thanks for the guidance :)
     
    Kurt-Dekker likes this.