Ladies and gentlemen, welcome back to another tutorial post here on The Creation Process! It has been a very, very long time since I last wrote a tutorial as I’ve been very busy with Min! But now with Min done and having achieved critical success (featured in over 50 publications – lots of positive reviews), wracking up a huge number of downloads, and even making its way on meta-critic! (Yes I know it is only one review but still… not bad for my first release!). As I find myself with more time on my hands and as I begin to contemplate what exciting things are currently in the works I decided, it is about time I wrote some more tutorials.
I will be focusing the tutorials mostly on iOS related topics and issues drawn from my experience with Min. When I first started writing the code for Min, UDK-Mobile was still relatively new and it came with a lot of issues. Thankfully the technology has come a long way and many of the issues I’ve come across are now a thing of the past. In this first tutorial, I will only go over what you need to do to setup Game Center to work with Unreal. After that I’ll be talking about Achievements, Leaderboards, iAds, and so on.
Right! So setting up Game Center! You can actually find a lot of material about this online. UDN does a really good job explaining this. I’ll be going over the process, as well as mentioning some potential detrimental pitfalls that are really, really easy to fix if you know what is going on. Let’s get started!
iTunes Connect Setup
Funny enough, before we actually start working with Unreal we first need to make sure everything looks good in iTunes Connect. To make sure we are all on the same page, before you can actually do and test any iOS related tidbits, you need to have:
- iOS Developer License from Apple (99$/year)
- Access to iTunes Connect
- An App Setup in iTunes Connect
- Your Provisions & Devices Setup in the iOS Provision Portal
- Unreal Frontend Setup to build your game on your device
Unfortunately, getting all that setup can be rather tedious, and possibly frustrating, if you do not know exactly what you are doing. Fortunately a lot of these topics are covered in great details all over the internet. I’ll just be making sure a few necessary things are ready and working when it comes to iTunes Connect leaving the rest to you.
Potential Pitfall 1: this isn’t exactly a pitfall, but it is a slight annoyance I wish I paid attention to when first developing Min. When you create your App make sure you use a temporary name for the App. The way Apple does things (they might have changed things by the time you actually read this tutorial) you can only have an App Name reserved for a few months. If you do not release your game before the months pass, your name will be unreserved and you will be unable to reuse that name yourself. This can be frustrating (and is the reason Min was called Min – A Space Adventure and not Min: A Space Adventure) so keep that in mind.
When you create your App – make sure it is associated with the right Bundle-ID. You need to register your Bundle-ID in the iOS Provision Portal and not in iTunes Connect. Bundle-IDs usually are created in this form: com.companyname.gamename. Epic uses this example: com.epicgames.exploreue3. Feel free to name your Bundle-ID in whatever way suits you as long as it follows the necessary guidelines.
Once you have your App associated with the right Bundle-ID, you need to create your App, click on it, then head into Manage Game Center.
Adding What You Need
Now, the actual “Management” of Game Center in iTunes Connect can be the topic of its own tutorial. There is a ton of stuff you can do here, especially lately with groupings and all that new good jazz introduced by Apple. For the purposes of this tutorial set, we will be adding a few test Achievements and Leaderboards later in this tutorial series. For now, just keep in mind that you need to head back here (Manage Game Center) to create your Achievements and Leaderboards.
You also need to make sure you have Game Center Enabled in your game. Click on View Details (for your App) and scroll down to make sure Game Center is enabled.
A long while ago, UDK and UDK Mobile were actually separate. For a lot of good reasons, they were later combined. As a result, Game Center is not initially activated in the vanilla installation of UDK. You need to do a few steps that tell UDK that you do intend to use Game Center in your work.
Step One: Adding OnlineSubsystemGameCenter
Open up your DefaultEngine.ini file located under: UDKGame\Config\DefaultEngine.ini. Scroll down to where it says [UnrealEd.EditorEngine] and add the following line: +EditPackages=OnlineSubsystemGameCenter. This line should ideally be placed underneath +EditPackages=UTGameContent. Once that is done, your [UnrealEd.EditorEngine] category should look something like this:
;your game packages go here
Great! That’s pretty straight forward isn’t it? Not much room for error. Recompile the code-base (you can do so from inside Unreal Frontend) and look to make sure OnlineSubsystemGameCenter was compiled.
You can also head to UDKGame\Script or UDKGame\ScriptFinalRelease (depending on what settings you used in Frontend) and look for the OnlineSubsystemGameCenter.u file. If it is there, you are in good shape.
Now that we successfully added OnlineSubsystemGamecenter and compiled it, we can move onto the next step.
We now need to edit the IPhoneEngine.ini file. This file can be found under UDKGame\Config\IPhone.
Potential Pitfall 2: there are actually TWO iPhoneEngine.ini files in UDK! One is located in UDKGame\Config\IPhone while the other can be found in Engine\Config\IPhone. Make sure you edit the one located under UDKGame\Config\IPhone! Sounds silly, but I’ve troubleshooted other dev’s problems for hours only to realize they were working with the wrong ini. Mistakes happen, just make sure this one doesn’t happen to you.
Now, inside the IPhoneEngine.ini file, you need to make a couple of changes. The first one is very easy. Under the [OnlineSubsystemGameCenter.OnlineSubsystemGameCenter] category, make sure the Boolean bDisableGameCenter is set to false.
Potential Pitfall 3: if you are launching your game on your device, and you do not get the “welcome back” Game Center message, the most likely problem is that you have the bDisableGameCenter flag set to true. Doing so will completely disable Game Center (as the name suggests) so make sure the flag is set to false.
The second change you need to do is a bit more complicated. Under the same category ([OnlineSubsystemGameCenter.OnlineSubsystemGameCenter]) you need to add the prefixes used for both your leaderboards and achievements. Remember that Bundle-ID I mentioned earlier? Well you need to use that here. You need to add the following lines in the [OnlineSubsystemGameCenter.OnlineSubsystemGameCenter] category.
What we basically did here was add our unique Bundle-ID “com.mytestbundle.tuttest” and add to it “.achievement_” and “.leaderboard”. These were added to the following categories: UniqueAchievementPrefix and EpicUniqueAchievementPrefix for achievements, and UniqueCategoryPrefix and EpicUniqueCategoryPrefix for leaderboards.
By now, your [OnlineSubsystemGameCenter.OnlineSubsystemGameCenter] block should look something like this:
Later on in this tutorial series, when we actually cover adding achievements and leaderboards in iTunes Connect, this step will make more sense. Each achievement and leaderbaord has a unique ID.
The unique IDs will look something like this:
By adding these four lines, you can now access your Achievements and Leaderboards through code .
At this point you should be able to connect to Game Center. If you did everything right all you need to do is build your game through Unreal Frontend and deploy it onto your device. Once you run your game, after or during the UDK opening video, you should receive a prompt asking you to login to Game Center. When you see that, you know, you did everything right! Congratulations!
Before we conclude let’s discuss the final pitfall.
Potential Pitfall: 4
When you are developing your game, you do not have access to Game Center itself. Obviously, your game will only appear on Game Center when it is released. For testing purposes Apple sets you up with a Sandbox Game Center allowing you to test everything you need to thoroughly before going gold. In order to access the Sandbox Game Center, you need to make absolute certain that your device is logged out of Game Center.
To do this, just open up Game Center and sign out. When you launch your game again it should prompt you to log in to Game Center, however, you will notice a lot of stars and the word “Sandbox”.
Note: Keep in mind, you might need to create a new account from the prompt. Logging in using your actual Game Center account may or may not work (I honestly don’t recall).
And there you have it. At this point you should have everything setup, allowing you to connect to the Sandbox Game Center. Now that all this boring setup stuff is out of the way, we can move on to actual code! In the rest of this tutorial series, I will show you how you can actually deal with Achievements and Leaderboards in your game using UnrealScript.
As always, your feedback is much appreciated and if you have any trouble make sure to leave a comment and I’ll get back to you. This tutorial skipped over a lot of Apple related setups as I made the assumption you already have that covered. If you don’t, make sure you do that first.
If you enjoyed this or any other tutorial, subscribe, share it with your friends, and as always your awesome donations are always welcome.