question

slingchilders avatar image
slingchilders asked

Beginners question: realtime inventory manipulation

I'm new to PlayFab. I created a very simple shop for my players using Unity SDK. Players download the catalogue, buy items, and can see their inventory as a list. Simple stuff.

My question is how can I achieve some kind of real-time feeling for those operations? Obviously I need to send API requests, which take a second or two to arrive, it makes the whole interface seem slugish.

How do you guys do it? I thought of just assuming any transaction works if there is money, and just updating and checking in the background, is that a good way to go?

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

·
1807605288 avatar image
1807605288 answered

My first suggestion is to do the "Get" API calls before the player opens the inventory window. Like, immediately after login.

You can do "refresh" API calls at appropriate times. When inventory changes, you need to refresh the GUI, but you can do so after the API call is done (This is important - else the player is looking at out-of-date information).

When you can, you just have to cleverly hide the API call time when the player isn't looking at the data you're loading. In the end though, it's never completely seamless. If the inventory is still loading when the user opens the inventory GUI, then the inventory needs to display "loading" or something until the call returns. You always have to be prepared for when it didn't load seamlessly.

1 comment
10 |1200

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

1807605288 avatar image 1807605288 ♦ commented ·

Additionally, most API calls that change data don't require a full "GetInventory" refresh. If RevokeItem succeeds, then you know that itemInstanceId was removed from the inventory. You don't need a full refresh. Keep this in mind with your API calls which change something, most of them, you can modify the local in-memory inventory information, without calling GetInventory again. This applies to other systems like attributes and such as well.

0 Likes 0 ·

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.