More than one hero/character with their own equipment menu but shared inventory?

How would i go about modifying the Inventory system to enable that? Sorry if this has already been asked, i haven’t seen it. EDIT: Currently I do not need the action menu system or the pick up / drop system.

It’s a strange setup that no-one wants so no, it’s not been asked before.

I think (and @Brian_Trotter will have to correct me) you can just set up everything as normal, but just give all the characters a reference to the same inventory. That would mean the inventory will be on some ‘party’ object instead of a character, though. Then, we used a static Inventory.GetPlayerInventory() to find the player and return their inventory. You’d add a tag called ‘Party’ (or whatever) on this party object with the inventory and then find that instead.

public static Inventory GetPartyInventory()
    var party = GameObject.FindWithTag("Party");
    return party.GetComponent<Inventory>();

I may be simplifying this a lot and there are almost certainly things I’m not thinking about right now that will be affected

1 Like

Actually, it really is that simple.
In my case, I would make the GetPlayerInventory() come up with the solution and leave the rest of the UI code the same.

public static Inventory GetPlayerInventory()
    var party = GameObject.FindWithTag("Party");
    if(party!=null && party.TryGetComponent(out Inventory partyInventory))
          return partyInventory;
    else var player = GameObject.FindWithTag("Player");
    return player.GetComponent<Inventory>();

With this in place, it will work whether or not you choose the Party GameObject method or the single player method, and that’s the full refactor in the code.

That means you don’t have to go into the individual UI and change anything because the Inventory.GetPlayerInventory() will return the correct Inventory.

Make sure you put a SaveableEntity on the PartyInventory Go and set it’s UUID to “Party”.
The best part? I’m pretty sure you could put this in the PersistentObjectPrefab and never worry about it again.

Not all that strange. Look at most FInal Fantasy games and JRPG games in general. The party shares an inventory


Fair enough. Funny, though, the more I thought about it, the more it seemed feasible for my own party-based game. No more ‘giving’ stuff to other characters

1 Like

Thank you both for the help! How do I differentiate between the equipments of the different heroes? What I did is probably too simple to work: I unpacked the Inventory Canvas Prefab Asset which basically consists of the equipment menu and the inventory and created 2 smaller prefabs so my new Party GO gets just inventory whereas my characters/heroes GOs get just equipment menus. This works fine if it was not the problem of duplicating ( I already messaged Brian about this and his solution to it, hoping that a solution which solves the issue for one character will also solve it for all) where equipping a weapon for example will duplicate the weapon across all slots within a single character equipment menu with type weapon and also across all characters who have equipment slot with type weapon.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms