question

ya-ralla avatar image
ya-ralla asked

Error trying to cloud save with Unity,Help with cloud save Unity

Hello, I am trying to setup a cloud save for a WebGL game made with Unity. Iv tried this POST but on Event History i get this:

player_executed_cloudscript

FAILED: UpdateUserData()(revision 4)

Btw, I am a noob programmer, thank you, this is the code:

private void OnLoginSuccess (LoginResult result)
    { 
	updateUserData ("keyNameTest", "saveStringTest");  

    }
public void updateUserData (string keyname, string value)

    {
        ExecuteCloudScriptRequest request = new ExecuteCloudScriptRequest {

            FunctionName = "UpdateUserData",

            GeneratePlayStreamEvent = true,

            FunctionParameter = new Dictionary<string,object> { { "keyName", keyname }, { "valueString", value } }

        };  

    }

,

Hello, I am trying to setup a cloud save for a WebGL game made with Unity. Iv tried this POST but on Event History i get this:

player_executed_cloudscript

FAILED: UpdateUserData()(revision 4)

Btw, I am a noob programmer, thank you, this is the code:

private void OnLoginSuccess (LoginResult result)
    { 
	updateUserData ("keyNameTest", "saveStringTest");  

    }


public void updateUserData (string keyname, string value)

    {
        ExecuteCloudScriptRequest request = new ExecuteCloudScriptRequest {

            FunctionName = "UpdateUserData",

            GeneratePlayStreamEvent = true,

            FunctionParameter = new Dictionary<string,object> { { "keyName", keyname }, { "valueString", value } }

        };  

    }

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

You are calling ExecuteCloudScriptRequest, for a simple UserData update, which would be better done with a direct call to UpdateUserData.

There is likely an error in your Cloud Script code. If you are trying to do a complex update in Cloud Script, then you will need to share THAT code, instead of your client code. Otherwise, I think you'd be better off just calling UpdateUserData directly.

8 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.

ya-ralla avatar image ya-ralla commented ·

Yep, thank you and sorry guys, after searching I found this Using Player Data , it works like a charm at least for me and without using Cloud Script. Have to try if all is ok and there are no problems when all those players are autosaving that long string every 1 minute.

0 Likes 0 ·
1807605288 avatar image 1807605288 ♦ ya-ralla commented ·

Saving every minute is not ideal.

First, you should make sure to only save if something has changed. Re-saving the same data over and over again is pointless and expensive for us.

Also, you should consider a larger delay like 5-15 minutes, and special events like program shutdown and/or logoff.

Or just design the game so it has explicit "save" points where the player triggers the save.

0 Likes 0 ·
ya-ralla avatar image ya-ralla 1807605288 ♦ commented ·

Ok thanks I ll try to delay the auto save and allow the user to manual save, problem is that my game is an idle game and progress is constant but I think there is no problem to delay the auto saves. Thank you!

0 Likes 0 ·
Show more comments
ya-ralla avatar image ya-ralla commented ·

To reconnect I just need to call the same function LoginWithKongregate() ?

0 Likes 0 ·
brendan avatar image brendan ya-ralla commented ·

That would get you a new session ticket, yes. Please note that you should always be checking for any errors coming back from API calls, as well. That way, if you do get the NotAuthenticated error back, you know that you need to re-authenticate the player via a Login call.

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.