• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by JeanFinley · Oct 06, 2021 at 12:22 PM · steamachievements

Can't Get Or Set Achievements With Steamworks.NET

I'm using Steamworks.NET to set up Steam ac$$anonymous$$evements in the game I'm working on. The SteamManager is initialising properly, the App ID is properly set and the ac$$anonymous$$evements have been published. Calling GetAc$$anonymous$$evement however, returns false. SetAc$$anonymous$$evement has the same problem and the UserAc$$anonymous$$evementStored_t callback is never called. All of the other calls to the Steamworks API return true and their callbacks are triggered with no errors.

Any ideas as to why these calls are returning false or anyt$$anonymous$$ng else to check would be appreciated.


Here's my code:

 public class SteamAc$$anonymous$$evementManager : Ac$$anonymous$$evementManager
 {
     List<Ac$$anonymous$$evementID> ac$$anonymous$$evementQueue = new List<Ac$$anonymous$$evementID>();
     List<Ac$$anonymous$$evementID> backupAc$$anonymous$$evementQueue = new List<Ac$$anonymous$$evementID>();
 
     private Callback<UserStatsReceived_t> statsRequestedResult;
     private Callback<UserStatsStored_t> statsStoredResult;
     private Callback<UserAc$$anonymous$$evementStored_t > ac$$anonymous$$evementStoredResult;
 
     bool awarding = false;
 
     int retryCount = 0;
     int maxRetryCounts = 5;
 
     public override void Init()
     {
         if( !SteamManager.Initialized )
         {
             Debug.LogError( "Tried to Init SteamAc$$anonymous$$evementManager but SteamManager is not initialised" );
             return;
         }
 
         //Steamworks.SteamUserStats.ResetAllStats( true );
 
         statsRequestedResult = Callback<UserStatsReceived_t>.Create( OnStatsReceived );
         statsStoredResult = Callback<UserStatsStored_t>.Create( OnStatsStored );
         ac$$anonymous$$evementStoredResult = Callback<UserAc$$anonymous$$evementStored_t>.Create( OnAc$$anonymous$$evementStored );
 
         SteamUserStats.RequestCurrentStats();
     }
 
     public override void AwardAc$$anonymous$$evement( Ac$$anonymous$$evementID ac$$anonymous$$evementID )
     {
         if( !SteamManager.Initialized )
         {
             Debug.LogError( "Tried to Award Ac$$anonymous$$evement but SteamManager is not initialised" );
             return;
         }
 
         ac$$anonymous$$evementQueue.Add( ac$$anonymous$$evementID );
         if( !awarding )
             AttemptToAwardAndStoreAc$$anonymous$$evements();
     }
 
     void AttemptToAwardAndStoreAc$$anonymous$$evements()
     {
         awarding = true;
 
         if( SteamUserStats.RequestCurrentStats() )
         {
             Debug.Log( "Successfully Requested Stats" );
         }
         else
         {
             Debug.LogError( "Failed to Request Stats" );
             CompleteAwarding( false );
         }
     }
 
     void OnStatsReceived( UserStatsReceived_t result )
     {
         if( result.m_eResult != EResult.k_EResultFail )
         {
             Debug.Log( "Successfully Received Stats " + result.m_eResult );
             AwardQueuedAc$$anonymous$$evements();
         }
         else
         {
             Debug.LogError( "Failed To Received Stats" );
             CompleteAwarding( false );
         }
     }
 
     void AwardQueuedAc$$anonymous$$evements()
     {
         List<Ac$$anonymous$$evementID> ac$$anonymous$$evementsToAward = new List<Ac$$anonymous$$evementID>( ac$$anonymous$$evementQueue );
 
         w$$anonymous$$le( ac$$anonymous$$evementQueue.Count > 0 )
         {
             Ac$$anonymous$$evementID ac$$anonymous$$evementID = ac$$anonymous$$evementQueue[ ac$$anonymous$$evementQueue.Count - 1 ];
             string steamID = Ac$$anonymous$$evementData.ac$$anonymous$$evementList.GetAc$$anonymous$$evement( ac$$anonymous$$evementID ).steamID;
             bool alreadyAwarded;
             Debug.Log( Steamworks.SteamUserStats.GetAc$$anonymous$$evementDisplayAttribute( steamID, "name" ) );
             if( !Steamworks.SteamUserStats.GetAc$$anonymous$$evement( steamID, out alreadyAwarded ) )
             {
                 Debug.LogError( "Failed To Get Ac$$anonymous$$evement: " + steamID );
             }
             if( !alreadyAwarded )
             {
                 if( Steamworks.SteamUserStats.SetAc$$anonymous$$evement( steamID ) )
                 {
                     Debug.Log( "Awarded Ac$$anonymous$$evement: " + steamID );
                 }
                 else
                 {
                     Debug.LogError( "Failed To Awarded Ac$$anonymous$$evement: " + steamID );
                     backupAc$$anonymous$$evementQueue.Add( ac$$anonymous$$evementID );
                 }
             }
             ac$$anonymous$$evementQueue.RemoveAt( ac$$anonymous$$evementQueue.Count - 1 );
         }
 
         SetStats();
     }
 
     private void OnAc$$anonymous$$evementStored( UserAc$$anonymous$$evementStored_t result )
     {
         Debug.Log( "Ac$$anonymous$$evement Stored Callback" );
     }
 
     public void SetStats()
     {
         SteamUserStats.StoreStats();
     }
 
     private void OnStatsStored( UserStatsStored_t result )
     {
         if( result.m_eResult != EResult.k_EResultFail )
             Debug.Log( "Ac$$anonymous$$evement Stats Succesfully Stored" );
         else
             Debug.LogError( "Ac$$anonymous$$evement Stats Failed To Store" );
 
         CompleteAwarding( result.m_eResult != EResult.k_EResultFail && backupAc$$anonymous$$evementQueue.Count == 0 );
     }
 
     void CompleteAwarding( bool wasSuccesful )
     {
         awarding = false;
         retryCount = wasSuccesful ? 0 : retryCount + 1;
         ac$$anonymous$$evementQueue.AddRange( backupAc$$anonymous$$evementQueue );
         backupAc$$anonymous$$evementQueue.Clear();
 
         if( retryCount > maxRetryCounts )
         {
             Debug.LogError( "Failed to Award Ac$$anonymous$$evements After Multiple Attempts" );
             retryCount = 0;
         }
         else if( ac$$anonymous$$evementQueue.Count > 0 )
         {
             retryCount++;
             AttemptToAwardAndStoreAc$$anonymous$$evements();
         }
     }
 }



Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by JeanFinley · Oct 07, 2021 at 10:01 AM

Turns out the app ID was wrong (figured that out by printing result.m_nGameID in OnStatsStored). I was convinced I had the correct ID because when I imported the package, there was a steam_appid.txt file created inside the Steamworks plugin folder, w$$anonymous$$ch I had changed to have the correct id. However there's another steam_appid.txt file in the project root folder, w$$anonymous$$ch is where the id is pulled from and t$$anonymous$$s one still had the wrong id.

So essentially I herped before I derped. All working now!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

128 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Steamworks.net achievements issue 1 Answer

Why in unity editor l can get steam achievements, but without the editor l can't? ! 1 Answer

How to setup achievements in uwp...? 0 Answers

steam achievements popping all on editor but not while playing the game on steam 0 Answers

Steamworks.NET - Trying to get achievement name 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges