question

brendan avatar image
brendan asked

How to make and manage equippable items?

Toby Thomson
started a topic on Sat, 21 March 2015 at 10:18 AM

Hi PlayFab,

I am at my wits end here. I have been trying to implement an equipped feature into my game. I have previously posted on this and I was pointed in the right direction however I just cannot see how one is meant to implement this. Basically if I have two items of class lets say vegetable, and I only want to have one vegetable equipped at a time in my game while still owning both. How am I to know which is equipped. Last time I asked this I was told to create a property on both items called "Equipped" and then set that to true or false for each item in a players inventory. However I don't think I can set custom properties individual of each instance of an item. In short is there a way to make some items equippable so that a user can have two items of the same type in their inventory but only have one equipped at a time?

My final question on this subject is that if I can create equippable items how would go abut making it so that when I equip an item of a certain class all the other items of that class in my inventory would be unequipped?

Thanks in advance

Toby

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Best Answer
Brendan Vanous said on Thu, 07 May 2015 at 4:17 PM

One more quick update: We now have custom data available for inventory item instances, as well:

https://api.playfab.com/Documentation/Server/method/UpdateUserInventoryItemCustomData

Enjoy!

Brendan


9 Comments
Brendan Vanous said on Mon, 23 March 2015 at 1:33 PM

Hi Toby,

Sorry to hear you're still stuck on this. We don't have a pre-built concept of equipment slots, as that's fairly game-specific. What I was describing in the previous post was:

Use the metadata for the item in the game Catalog to inform your game of whether the item is equip-able, and what "slots" (or similar) it can go in.

Then, in UserReadOnlyData (you can use Cloud Script to update this, so that you can have validation checks, to prevent cheating). you would have a key/value pair of something like:

"RightHand": "Vegetable1"

When the player chooses to equip "Vegetable2" in that slot, you would update that key with the new value.

Make sense?

Brendan


Toby Thomson said on Mon, 23 March 2015 at 2:38 PM

Thanks Brendan

I was attempting to solve by having an item say weather not it is equipped rather than have slots which have items in them. Your method is a brilliant solution and I shall be using it! I would however recommend that a string status propriety for items is implemented

Thanks a tonne

Toby


Brendan Vanous said on Thu, 07 May 2015 at 4:17 PM

One more quick update: We now have custom data available for inventory item instances, as well:

https://api.playfab.com/Documentation/Server/method/UpdateUserInventoryItemCustomData

Enjoy!

Brendan


Toby Thomson said on Sat, 09 May 2015 at 8:42 AM

Thanks. But how would one go about accessing this data using the Unity C# API in the OnGetUserInventoryResult method?


Brendan Vanous said on Sat, 09 May 2015 at 10:14 PM

The item instance returned now also has a CustomData field as part of the returned data - you'll need to update to the latest version of our SDK, to see this.

Brendan


Toby Thomson said on Sun, 10 May 2015 at 4:27 AM

Thanks! All cleared up


moys said on Mon, 07 September 2015 at 6:36 AM

Hi,

I know this is an old thread but i have a question about CustomData field on the ItemInstance.

I have the latest UnitySDK from GitHub. I set up an item with some custom attributes and granted it to the player.

Now if I use GetCatalogItems I see the CustomData is returned.

But if I use GetUserInventory I see no CustomData attribute in the response(not the response string).

Could you please give me a little help how can I investigate the issue?

Br,

G


Brendan Vanous said on Mon, 07 September 2015 at 1:29 PM

Hi Gabor,

Any custom data set on an inventory item appears in the CustomData field of the item instance. I think the confusion here is that the CustomData you're setting at the catalog level does not propagate to the item instances. The idea is that the CustomData is the catalog is global, so that you can update it once in the catalog, and then use that data for all players. To set CustomData for an inventory item instance, you need to use UpdateUserInventoryItemCustomData.

Brendan


moys said on Mon, 07 September 2015 at 9:57 PM

Hi,

Thanks for the fast reply. It's clear now.

Br,

G

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.