Steam achievements in Godot with GodotSteam
2 min read
By Eduardo Orellana ·
To add Steam achievements to a Godot 4 game: create them (and any stats) in Steamworks and publish the change (the game does not need to be released), then in GDScript call Steam.setAchievement("API_NAME") followed by Steam.storeStats(). storeStats() is what uploads it and triggers Steam's pop-up. Read one with Steam.getAchievement(), clear it with Steam.clearAchievement(). GodotSteam 4.14 and later sync stats and achievements at boot, so no request call is needed.
The pop-up only appears after storeStats()
The most common achievement bug in Godot is not a bug: the achievement is set but never stored. setAchievement() marks it locally; storeStats() sends it to Steam, and only then does the overlay pop-up appear. Call both.
In Steamworks
- Create each achievement with an API name, display name, description and locked and unlocked icons.
- Create any stats (integer or float, and whether they only increase).
- Publish the changes. Until you do, setting or reading them returns errors. The game does not need to be approved or released.
In GDScript
With GodotSteam initialized in an autoload, unlock an achievement by its API name:
func unlock(api_name: String) -> void:
if not Steam.setAchievement(api_name):
push_warning('No achievement called %s' % api_name)
return
Steam.storeStats()
func add_kill() -> void:
var kills: int = Steam.getStatInt('kills')
Steam.setStatInt('kills', kills + 1)
Steam.storeStats()Reading, resetting, testing
- Read: Steam.getAchievement(name) returns a dictionary; ret is false if the achievement does not exist, achieved tells you its state.
- Clear one: Steam.clearAchievement(name), then storeStats().
- Reset everything: Steam.resetAllStats(true) also resets achievements. Useful while testing.
- Increment-only stats refuse a lower value.
- Test with Steam running and signed in, under your game's own App ID once the achievements exist there.
Where Flockbay fits
Flockbay builds games on the official Godot engine; ask its AI for Steam achievements and it writes the GodotSteam calls into your project, which you own. Building is free.
Questions
- Why does my Steam achievement not pop up in Godot?
- Usually because Steam.storeStats() was not called after Steam.setAchievement(), or the achievements were not published in Steamworks.
Keep reading
- The indie game publishing guide
- GodotSteam setup
- Port a Godot game to Steam
- Steam achievements in Unity
- How to put an RPG Maker game on Steam
- Invalid access to property or key '…' on a base object of type 'Dictionary' in Godot 4
- How to put a Unity game on Steam
- Steam Cloud saves for a Godot game
Flockbay builds Godot games for free and writes Steam features into them on request.
Download Flockbay free