0
Answered

Keeping track of what is equipped outside Inventory ui

Tobias T 7 months ago in Inventory updated by Marti (Lead Developer) 7 months ago 1

I want to let the player pick up any number of things in the world, but only have 10 items available for use while playing the game. Very similar to what minecraft has.


In short, I want to have a game object which keeps track of what is equipped, so I have one place where I do things with them. Like selecting which is the active one, etc.

Let's call it EquippedState.

For this I guess I need to communicate that the item has been equipped to my EquippedState. Any idea how I would go about doing that?

And a second question is, how would I go about un-equipping things using the Inventory? To "put my sword away" when entering a town in order not to scare people.

I managed to Equip it by clicking on the item (added an Action which did this). But I can't find a way to do the opposite.

(I noticed that if I equip two of the same type, the first is unequiped)

I am still pretty new to the Game Creator way of thinking, so there are quite a few concepts that I find a little hard to grasp.

Inventory version 1.0.1

Unity version:
2018.4.17f1
Game Creator version:
1.1.5

Answer

Answer
Answered

Hi Tobias;

Sorry for the late reply. In order to do that, you can use the On Equip and On Unequip actions callback that are present in any equippable item. Simply mark a boolean flag as true or false whenever a certain item is equipped, or call a method from your custom script (that's what the EquippedState represents, if I guessed correctly).

As for the second question, it's as easy as using the Unequip action.

Answer
Answered

Hi Tobias;

Sorry for the late reply. In order to do that, you can use the On Equip and On Unequip actions callback that are present in any equippable item. Simply mark a boolean flag as true or false whenever a certain item is equipped, or call a method from your custom script (that's what the EquippedState represents, if I guessed correctly).

As for the second question, it's as easy as using the Unequip action.