Achievements Examples
This section demonstrates practical examples of using Google Play Games Services Achievements in real Unreal Engine projects. All examples assume that the player is already signed in to Google Play Games Services and that all achievements have been created and configured in the Google Play Console in advance.
The examples focus on common gameplay scenarios and recommended usage patterns rather than listing every available function.
Basic Usage Flow
A typical achievements flow in a game looks like this:
- The player signs in to Google Play Games Services.
- Achievements are loaded once, usually when entering the main menu or after sign-in.
- Gameplay logic unlocks, reveals, or updates achievements when specific conditions are met.
- The native achievements UI can be opened from a menu or button when needed.
Loading Achievements on Game Start
Achievements are usually loaded once after the player has signed in. This allows the game to know which achievements are already unlocked, revealed, or in progress.
It is recommended to call Load Achievements with bForceReload set to true. This ensures that the data is always fetched from the Google Play Games Services backend and reflects the most up-to-date achievement state. In practice, the performance difference compared to cached loading is negligible.
The loaded achievements list is typically stored in a variable or manager and reused throughout the game to check achievement states and drive gameplay logic or UI.
Typical usage pattern:
- Call Load Achievements after the player has successfully signed in.
- Enable
bForceReloadto always receive fresh data from the server. - Store the returned array of
FGooglePlayAchievementin a variable. - Use the stored achievement state to decide when to unlock, reveal, or update achievements.
This approach keeps achievement state consistent across devices and sessions while remaining simple and reliable.
Showing the Achievements UI
Most games provide a dedicated button in the main menu or pause menu to display achievements.
In this example, pressing an “Achievements” button opens the native Google Play Games achievements UI.
Typical usage pattern:
- Call Show Achievements UI when the button is pressed.
- Use On Opened and On Closed callbacks to pause and resume gameplay if required.
- Handle On Failure to gracefully report or log UI errors.
Using the callbacks is optional, but handy when you need full control over gameplay flow while the achievements UI is visible.
The native achievements UI is fully managed by Google Play Games Services and does not require any additional configuration or setup.
Unlocking a Standard Achievement
Standard achievements are unlocked once when a specific condition is met.
Example scenario: unlock an achievement when the player completes the first level.
Typical usage pattern:
- Detect the gameplay condition (for example, level completion).
- Call Unlock Achievement with the corresponding
AchievementID. - The
AchievementIDmust exactly match the identifier of the achievement created in the Google Play Console.
Calling this function multiple times with the same ID is safe. If the achievement is already unlocked, Google Play Games Services will ignore the request.
Working with Incremental Achievements
Incremental achievements track progress across multiple steps and are commonly used for long-term goals.
Incrementing Progress
Example scenario: increment an achievement every time an enemy is defeated.
- Call Increment Achievement with the corresponding
AchievementID. - Pass the number of steps to increment, usually
1.
This adds progress on top of the existing value.
Setting Absolute Progress
In some cases, you may want to explicitly set the current progress value.
Example scenario: sync achievement progress from a save file.
- Call Set Achievement Steps with the total number of completed steps.
- This overwrites the current progress value.
This approach is useful when restoring progress after loading a game.
Revealing a Hidden Achievement
Hidden achievements can be revealed before they are unlocked to hint at upcoming goals.
Example scenario: reveal a hidden achievement after the player reaches a specific story milestone.
- Call Reveal Achievement with the corresponding
AchievementID. - The achievement becomes visible in the achievements UI but remains locked.
This does not unlock the achievement and does not grant rewards.
Important Notes and Common Mistakes
- All achievement functions require the player to be signed in to Google Play Games Services.
- Achievement IDs must exactly match the IDs defined in the Google Play Console.
- Incremental achievements must be configured as incremental in the Google Play Console.
- Standard achievements should not be incremented or have steps set.
- Achievement data may be cached locally unless a forced reload is requested.
- Unlocking or updating achievements is safe to call multiple times for the same condition.
These examples cover the most common achievement usage patterns and are sufficient for most games, from small projects to full production titles.