question

westenmasterson avatar image
westenmasterson asked

Unreal Engine 4 Blueprints Update Player Data JSON object issues

I'm having trouble being able to store data in the Player Data with Unreal Engine 4 Blueprints. Currently I have a setup that will store data correctly but only if I use the "Set Object Array Field" node but will not work with the "Set Object Field" node. To keep track of what levels a character is on and where they are in that level we want to have one Key-Value pair that will contain a JSON object with an array of data for the levels (Key - Levels, Value - Array of Levels with Level Status)

I've been trying to do some tests to make sure we can in fact store that data via UE4 Blueprints but I keep hitting roadblocks.
Here is an example of storing a test boolean in a JSON object and then sending that to the player. When I do this using the "Set Object Array Field" it works, though I get a Key with an [0] appended on. When I do it with the "Set Object Field" nothing is stored in the player. What am I missing and not understanding about how this works?





unreal
3 comments
10 |1200

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

JayZuo avatar image JayZuo ♦ commented ·

Could you please share the code you are using now?

0 Likes 0 ·
westenmasterson avatar image westenmasterson JayZuo ♦ commented ·

Oh yes sorry. I thought I did, but the pictures didn't post.
First picture is the code I use. It only works when I use the Set Object Array Field, but even then not quite how I want it to.



The second is the result of using Set Object Array Field. Whereas if I use Set Object Field it comes out blank.


playfabdata.png

0 Likes 0 ·
updateuserdata.png (423.1 KiB)
playfabdata.png (11.8 KiB)
westenmasterson avatar image westenmasterson JayZuo ♦ commented ·

For reference this is what I would want to end up with in the end. finalstate.png

0 Likes 0 ·
finalstate.png (15.1 KiB)

1 Answer

·
JayZuo avatar image
JayZuo answered

The problem here is that UpdateUserData only support string/string key/value pairs in its Data object. You can check this by editing some values to JSON objects in Game Manager and then get them with GetUserData. You will find all JSON objects are Stringfield.

Thus, to achieve what you want, you can try with the follow code:

https://blueprintue.com/blueprint/zkr5u6os/


663rd.png (177.0 KiB)
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.