The WordPress Achievements plugin for WordPress Login truly is a very simple product to understand and use. Once you understand how it works you will be able to use it like a boss in no time at all. For that reason let me give you the background info first and then end off with how you can get started using the kit…
Should you want to, you can also add:
– text to display when the achievement has been unlocked
– text to explain to the player how they can unlock the achievement
– any number of requirements to test if an achievement can be unlocked
That’s it. That easy.
Like I said. Very simple to understand and use.
Not really. I tried to keep it as functional but as simple as humanly possible. You create the achievement, you get the ID, you decide when to award it and when you are ready you just call UnlockAchievement(int) and on the back end everything is hunky dory. That only leaves the front end… i.e. how do you show the achievements in Unity?
That, however, depends on each individual game. I provide you with a host of functions so that you can decide for yourself how you want to display the achievements in your game but I also include a fully functional prefab to use as a reference.
Using this system boils down to this:
Inside this prefab I make provision for awards that you can unlock manually in case you want to use your own award tracking system but I also make provision for awarding the achievements on your behalf if you set the requirements on your website. As a bonus feature, if the image you wish to display is found in a Resources folder in your project the prefab uses the local image instead of fetching it from online. If the image is not found then it will go fetch it.
The requirements system allows you to define specific unlocking conditions directly on your website and thus allows you to change the requirements even after the game was published.
Simply put, simply decide when something of importance has happened in your game and then store a key to indicate it has happened. Every time you update a key the prefab will store it so that the event(s) that happened persist between play sessions. It then loops through each locked achievement with server side defined requirements and checks each requirement to see if any achievement now fulfils the unlock requirements. If it does then it is unlocked.
For the demo scene I created some buttons above the prefab to allow you to simulate what would happen in game when you award or remove keys and also allow you to manually toggle awards on or off.
Game keys are how I track game progress in the demo prefab.
They are simply strings and can be anything you want them to be but includes a value to indicate how many of those keys you currently hold.
gold, level, enemy_kills, headshots, reputation… quite literally anything you want.
While the game is playing, whenever something of any importance happens, simply add a key to keep track of how many times this “something” has happened thus far. For example, say your character does a head shot… You would just call:
With that single line of code you now have one more head shot key than you had before.
In your dashboard, when you define your achievement, you can add as many requirements as you like for each achievement. All requirements must be met before it is considered unlocked by the prefab.
Each requirement consists of 3 fields.
The first is selected via a drop down box to determine if this achievement:
…the amount of keys you specify.
The second field is a text field where you specify the name of the key (case sensitive). The final field is a number representing how many keys would qualify this requirement as being met. All requirements must be met before an achievement is unlocked.
Let’s say you create an achievement called “Master Sniper” and you set three requirements.
After setting the three values for each of your three requirements they will essentially read like this :
IF you have AT LEAST 10 HeadShots keys
AND you have LESS THAN 1 Missed keys
AND you have EXACTLY 3 Lives keys
THEN receive the Master Sniper achievement.
You can make this as simple as “Killed at least 100 Orcs” or you can make an achievement have 500 requirements. How easy or difficult you make it is entirely up to you.
While playing the game you just call UpdateKeys whenever something happens and the prefab will keep checking all the various keys against all the various requirements of all the locked achievements and award the achievements when appropriate. You just sit back and relax.
You can have two types of awards:
In both cases you will need a way to track what the player has and has not done so you might already have another system in place and would prefer to use that method instead. With method two, above, the prefab takes care of storing and retrieving your progress for you and truly automates the entire process.
That is all there is to it. You can now run the demo and see the achievements you created on your website. Feel free to play around with adding and removing keys and seeing what happens.
© 2019 myBad Studios