Search Unity

Inventory Item Containers / Multiple Inventories

Discussion in 'Game Foundation' started by ShadyAlien, Jul 20, 2020.

  1. ShadyAlien

    ShadyAlien

    Joined:
    Aug 28, 2009
    Posts:
    210
    Hello!

    I'm trying to evaluate whether to use Game Foundation for my project or not--there's lots of aspects of it that are very appealing to me, especially from an item management standpoint.

    However, looking through the example code and documentation there's a couple things I'm unclear on.

    Specifically, I want to implement multiple inventory containers. It seems that the inventory manager is designed for managing the player's inventory only, but I also would like this functionality for other things. I would like to have containers that the player can put things into and take things out of (and in some cases, be limited in what type of items it can receive), and ideally these containers could also be used for transactions (put things in container -> get new thing out). So, this would be a little bit different than simply giving or removing items from the player, since those items need to be transferred from one inventory to another etc.

    Essentially, what I'm looking for is a system akin to Skyrim or other Bethesda games, where containers and characters all have their own inventory lists that all behave pretty much the same. Is there a relatively straightforward way to implement something like this, that would also work with the data layer for saving/loading?
     
    Last edited: Jul 20, 2020
    martyparty1535 and erika_d like this.
  2. mingz-unity

    mingz-unity

    Unity Technologies

    Joined:
    Oct 12, 2017
    Posts:
    63
    HI @ShadyAlien thanks for reaching out to us -

    It's true that Game Foundation is currently optimized for a single-collection inventory system for its simplicity and ease of use. For the scenario you described, there're a couple of ways you may get this to work:

    1) Using tags to label the type of containers that a specific item should belong to, this works well if the relationship between the container and item is always clear, and you can then simply filter by a specific tag to get those items.

    2) Define a mutable property to indicate the location or other runtime context for your specific need, so that while the item being managed is flat internally in Inventory Manager, you can filter to specific list of items based on the custom properties to help you distinguish which container the item is currently located at.

    For supporting transactions, this may just work out of the box today if the input and output items in those resource transformation are different, i.e. you consume certain items while giving out new items, and the new ones can have certain runtime properties like I mentioned above to indicate where they below to. Commonly such resource transformation may not be specific to the location, but more tied to the types of item (i.e. item definitions), and Game Foundation virtual transaction system support item - item transformation quite easily.

    Hope this helps. We are currently also working on multi-collection support for the inventory system which may help a bit more, and it could be available in the next few weeks. But let us know if the above approach could work for you, or any additional questions.
     
    erika_d and saskenergy like this.
  3. ShadyAlien

    ShadyAlien

    Joined:
    Aug 28, 2009
    Posts:
    210
    Thanks for the info! I will experiment with both of those options.
     
    erika_d likes this.