Search Unity

Inventory items within inventory items?

Discussion in 'Game Foundation' started by mikko_to, Feb 2, 2021.

  1. mikko_to

    mikko_to

    Joined:
    Oct 14, 2013
    Posts:
    21
    Is it possible to insert inventory items within inventory items or is this kind of functionality planned to be implemented? Example for this could be:

    Weapon which has slots for inserting various gems, which would then boost the weapon performance. Gems itself would be inventory items the player can collect in the game.

    Currently Inventory Item definitions can have resources assets as mutable properties, so I was thinking the solution would be similar, but instead of resources asset this would be Inventory items. Even better, tags could be set to control which kind of Inventory Items can be inserted into these slots. So, a banana with a tag "Food" cannot be inserted into the weapon, but a diamond with a tag "Gem" could be.

    I was thinking of creating own class Weapon and handling this functionality there, but to my understanding being able to save and load this within Game Foundation system would need some separate constructor / de-constructor and this doesn't sound like a first option forward.
     
    erika_d likes this.
  2. richj_unity

    richj_unity

    Unity Technologies

    Joined:
    Sep 23, 2019
    Posts:
    36
    Hi @mikko_to,

    In Package Manager under Game Foundation, check out the two samples named Item Lists and Item Maps. You could create a List or Map that represents the upgrade slots of a weapon. You would have to keep track of that association yourself though. Please let us know if you have any questions about how Item Lists/Maps work.

    We don't have anything for defining automatic interaction rules between Inventory Items (or Lists/Maps), but you can add tags to Inventory Items in the editor and then access them at runtime.
     
    erika_d likes this.
  3. mikko_to

    mikko_to

    Joined:
    Oct 14, 2013
    Posts:
    21
    Thanks @richj_unity ! Checked those samples you pointed out and I think Item Maps is the way forward. Thanks for the guidance!
     
    erika_d and richj_unity like this.
unityunity