0

I have Steam account on multiple PC devices. Through my Steam client i installed a game on these devices. My game code is trying to unlock some achievements. These are getting unlocked on one device but not on the other. I made sure I am in online mode when unlocking the achievements. Also the achievements in question are straightforward gameplay and dont read stored stats (which are particular to the device). So technically if a gameplay code is triggered, the achievements should be unlocked. Why are these achievements getting unlocked on one device and not the other, although they are installed from the same account? My unity code is:

if (SteamManager.Initialized) {
    SteamUserStats.GetAchievement (achievementId, out isAchievementUnlocked);
    if (!isAchievementUnlocked) {
        SteamUserStats.SetAchievement (achievementId);
        SteamUserStats.StoreStats ();
    }
}
mukul
  • 171
  • 1
  • 15
  • 1
    I don't know any of this .. but what if the code is executed before `SteamManager.Initialized` ? Maybe you just need to wait until this is `true`? Maybe an issue with the execution order? – derHugo Mar 01 '23 at 12:43
  • You are right. It was not in sync. – mukul Mar 02 '23 at 10:19

1 Answers1

0

It has been a while since I used Steam SDK, but be sure to initialize the Steam SDK beforehand. Most of the SDK issues are related to this. Either SDK is not initialized yet or something else prevented invoking the method on SDK.

For the first, I would suggest you to print logs for initializing SDKs and other manager classes. This will help you identify some possible problems faster. To prevent logs for builds, you can use preprocessors, which will only be compiled depending on your condition.

For instance, you might need to print "Steam SDK Initialized" log only for development builds and / or Unity Editor.

A simple example would be like

#if UNITY_EDITOR
  Debug.Log("This code is compiled only if Unity Editor");
#endif

For more directives you can check out the documentation here

Also, if you have experienced this on a build, I suggest you to use development builds for testing which will show logs as well.

If it is not related to the initialization, back in the days we have experienced some SDK issues on some computers where we had to restart the Steam app for some Steam SDK things to work. Might still be a thing, just in case wanted to share my experience.

Excalith
  • 1
  • 2