Graphics and Games • iOS, macOS, tvOS, watchOS • 24:53
Level up your Game Center integration and enable players to compare scores on leaderboards, earn valuable achievements, and engage with other players. Organize special events like weekly championships, daily showdowns, or 1-hour competitions using recurring leaderboards. Create up to 100 unique achievements for your game. And we'll show you how to set up real-time or turn-based multiplayer matches for your Game Center players. If you want to learn more about Game Center’s interface, Dashboard, and player profiles, check out “Tap into Game Center: Dashboard, Access Point, and Profile.” And for more about preparing your game’s interface for these new capabilities, see “Design for Game Center.”
Speakers: Udayan Kale, Christy Warren, Dersu Abolfathi
Downloads from Apple
Transcript
Hello and welcome to WWDC. Hi, everyone. I'm Udayan Kale. I'm on the Game Center engineering team. In this session, we will be talking about all the new features in Game Center Leaderboards, Achievements, and Multiplayer. So let's talk about Game Center Leaderboards. I will do a quick recap of Game Center Leaderboards and then show you everything that's new this year. Leaderboards have always been an integral part of Game Center. A leaderboard is driven by scores and ranks players based on these scores. Players can view their friend and global ranks and challenge other players to beat their scores.
You can share leaderboards across versions of your games on iOS, tvOS and macOS. Game Center provides a lot of choices when it comes to configuring leaderboards and setting the score formats, scoring types and sort orders. Game Center leaderboards have always been the traditional non-expiring type. They maintain player scores and rankings forever. We now refer to these leaderboards as classic leaderboards. Here are a few examples.
A game wants to keep track of the overall total number of experience points earned by players, or the most coins that were collected, or the shortest time taken to complete a game level. These are all good use cases for classic leaderboards. So what's new this year? We now have a new type of leaderboard called recurring leaderboards.
We have also completely redesigned the in-game UI, and we have a new set of APIs to access leaderboard data and submit scores. I will cover the new UI and APIs later. For now, let's look at recurring leaderboards. Recurring leaderboards are short-lived leaderboards that repeat on a periodic basis. These leaderboards will be great if your game wants to support periodic timed events.
Here are some good use cases. You want your game to run a 15-minute competition every hour, or you want to host a one-hour challenge every Sunday at noon, or you just want to run a new leaderboard each week. Recurring leaderboards will give your players a fresh start every time to compete for top spots. Here is a deeper look at how Game Center recurring leaderboards work.
A recurring leaderboard is a sequence of individual timed leaderboards that start and end on a periodic basis. We call each of these individual leaderboards an occurrence. These occurrences are short-lived and do not overlap. Each new occurrence begins only after the current one ends. You configure a recurring leaderboard using a set of parameters in App Store Connect. Initial start date defines when your leaderboard will start creating occurrences. Frequency specifies the rate at which occurrences repeat, and Duration specifies the time during which scores can be submitted to an active occurrence.
You can introduce a time delay between occurrences using different values for Frequency and Duration. Each occurrence also maintains information about the start date of the next occurrence, so you know exactly when the next one begins. You can access each occurrence through an instance of the GKLeaderboard class. So let me show you how to configure the examples I mentioned earlier. In the first example, you have a 15-minute competition every hour at the top of the hour. You configure this leaderboard with a desired initial start date, a 60-minute frequency, and a 15-minute duration.
The second example describes a one-hour contest every Sunday at noon. You set the start date, a frequency of seven days, and a duration of 60 minutes. The third example shows a recurring leaderboard that runs daily with no gaps between occurrences. And to ensure that occurrences do not overlap, the duration must not be greater than the frequency.
Now that you know how recurring leaderboards are configured, let's talk about incorporating leaderboards in your game. The whole purpose of adding leaderboards to your game is to capture scores earned by players and display these scores so players can see their rankings. I will now show you how to submit scores to leaderboards.
Submitting scores to a classic leaderboard is easy because a classic leaderboard never ends. You just call the submitScore method, passing in a score, a context, player, and one or more leaderboard IDs. Context is an optional value that you can associate with the score. The leaderboard will retain either the best score or the most recent score.
For recurring leaderboards, scores can only be submitted to the currently active occurrence. You have two ways to submit scores to a recurring leaderboard. The first is to use the same method we used for classic leaderboards. The score will be posted to the currently active occurrence if one exists at the time of submission.
The second option is to use a method on the GKLeaderboard instance that corresponds to an occurrence. As long as that occurrence is active, score submissions will succeed. You can query the startDate and duration properties of GKLeaderboard to determine if the occurrence is active. Game Center defers forwarding scores to the server if the device is off-line. The server validates a score based on the time it's received, not when it was earned by the player. So it is possible that an active leaderboard occurrence may have expired when the score reaches the server.
Next, let's talk about displaying leaderboards in your game. You have two options when it comes to showing leaderboards within your game: using GameKit's new in-game UI or displaying your own custom UI. We strongly recommend using GameKit's in-game UI, as it's very easy to adopt and does most of the heavy lifting for you. For this, you will use the GKGameCenterViewController class that you may already be familiar with. In the previous session, I showed you how to invoke the Game Center Dashboard.
I'll now show you how to directly display a list of leaderboards within your game. You can see here I initialized the GKGameCenterViewController specifying the "leaderboards" state. This gives you a list of leaderboards that you see here on the right. At this point, the user can navigate to a particular leaderboard that they are interested in and select it. That will display the scores for that leaderboard.
On the scores view, players can see how they rank against friends, recently played, and global players. They can use the filter in the header area to change the time scope for classic leaderboards or the occurrence for recurring leaderboards. They can scroll to the top of the list by tapping on the name in the header.
You can even deep-link to a specific leaderboard to directly display scores. So here I have initialized GKGameCenter ViewController with a leaderboard ID, a player scope, and a time scope, and you get the scores view that you see on the right. So you see, adopting Game Center's in-game UI is that easy. But if you want to draw your own UI, you have to load the leaderboards and scores programmatically.
We have introduced new APIs to work with leaderboards and scores, and you can read about them in the developer docs. Recurring leaderboards need special handling when dealing with occurrences. When you load a recurring leaderboard, only the current occurrence is loaded. You can use this current occurrence to load a previous one by calling the method loadPreviousOccurrence, as shown here.
Here are some considerations to keep in mind when loading previous occurrences. Game Center keeps expired occurrences around for up to 30 days from their expiry. However, a signed-in player can view scores only on the current occurrence and one previous occurrence. The previous occurrence is usually the most recent expired occurrence in which the player submitted a score. In the example shown here, Player 1 can view their scores on the current occurrence, 53, and the previous occurrence, 50.
If a player never submitted a score to an occurrence, or if that occurrence was purged, then the immediate previous occurrence is accessible. So in the case of Player 2, they can view occurrences 53 and 52. If no occurrence is currently active, the most recent occurrence is still considered current for accessing scores.
Next, let's talk about setting up the leaderboards in App Store Connect. This screen shows the leaderboards for a typical game in App Store Connect. Most of the setup involving leaderboards, sets, and groups is the same as before and is common to both classic and recurring leaderboards. I will now show you the additional configuration you will need for recurring leaderboards.
To add a new leaderboard, just click the "plus" icon next to the section title. On the pop-up that shows, choose the type of leaderboard you wish to create. Your game can have just classic leaderboards or just recurring leaderboards or a combination of both. Once you select the type of leaderboard, you'll need to configure it.
For classic and recurring leaderboards, you must populate the section at the top. This is the same as you do today. The section at the bottom is only available for recurring leaderboards. The Start Date and Time specifies when your leaderboard will start creating occurrences. The Duration is the time interval during which scores can be submitted to an occurrence. And Restart specifies how frequently new occurrences will be created.
The Duration and Restart period are both specified in minutes, hours or days. The restart period must be equal to or larger than the duration so occurrences do not overlap. Once you have configured a leaderboard, you must localize it. Both classic and recurring leaderboards have the same options when adding languages.
We strongly recommend that you upload an image for your leaderboard that reflects some aspect of your game. This image is prominently displayed in the in-game UI. So that's it for Game Center Leaderboards this year. We cannot wait to see games adopting these new features in various creative ways. Next up is Achievements, and for that, let me welcome Dersu. Thank you.
Thank you, Udayan. Let's talk about Achievements in Game Center. So, what is an achievement? An achievement is a collectible item indicating the player has successfully reached a particular goal in your game. Achievements have been a fundamental part of Game Center since its inception, as they provide players an additional way of engaging with the game, tracking gameplay progress, and sharing that progress with friends. Players will notice a fresh, new and consistent look to achievement badges. As the developer, you define the achievements available for players to work towards. An achievement will appear to players in one of four forms: locked, in-progress, completed, or hidden.
Before the player has made any progress toward an achievement, it will appear locked. Some players will often scan the achievements list and browse locked achievements as a guide for what they should do in your game. In this sense, your achievements list gives you an opportunity to tell users what to think about while playing your game. After you start reporting progress for a user toward some achievement, it will display as in-progress.
Once you report 100% progress for that achievement, it is considered complete. At this point, the user will see the image tied to the achievement, and it will show up in their list of completed achievements. Last, you can explicitly mark an achievement as hidden until the player has completed it.
You might do this if you feel the achievement description itself prematurely reveals aspects of the game's story or plot. Alternatively, consider using hidden achievements to surprise, delight or humor the player. For example, you might include a hidden achievement that rewards the player for failing spectacularly. This year, we're bringing Achievements to more places, including the Game Center Dashboard on iOS, macOS, and tvOS.
The Dashboard is a brand-new area for players to view Game Center-related information for your game. It's accessible straight from your game, and it showcases your game's achievements, personalized according to the player's progress. This means it's as important as ever to make sure your achievements are engaging, accessible, and interesting for players.
For some useful tips and best practices for building achievements, we recommend you check out this year's session "Design for Game Center." Before finalizing your achievements design, it's important to keep in mind that there are limits to how many you can include in your game. Your game can have a maximum of 100 achievements, each of which can award up to 100 points. And overall, your game can award up to 1,000 points. You'll want to make sure you make the most of this budget, creating a set of achievements that require a range of skills and dedication to complete.
Finally, you should keep these limits in mind when shipping the initial version of your game, as you may want to create new achievements for future updates. After you've designed some achievements, you're probably ready to start integrating them into your game. And there are three simple steps needed to do this. First, you'll need to authenticate the local player. Without first authenticating, any API calls you make to GameKit will result in an error.
For more on using the local player, refer to session "Tap into Game Center: Dashboard, Access Point, and Profile." Next, you need to report the player's progress to GameKit. As long as GameKit maintains a progress of zero for an achievement, it's going to appear to the player as locked. But the most interesting part of achievements happens when the player makes progress in your game. You'll notice in-progress achievements have been completely redesigned. Game Center will present players with this brand-new styling, which features a progress circle, enticing them to get back into your game.
Unsurprisingly, reporting achievement progress is done through the GKAchievement class. Every achievement has a unique identifier, which you use to initialize the GKAchievement. Anytime the player makes progress towards that achievement, it's important to update that percentComplete property. Finally, you can call the report method to register that change and handle any potential errors.
Now the player will see their achievement progress update anywhere they see this achievement, and they will unlock its imagery if it's completed. Finally, let's talk about how we can show the player their achievements. Achievements have a brand-new home in the Game Center In-Game Dashboard. If you integrate the new Access Point, this dashboard is just one tap away for the player in your game. The Achievements tab is front and center, giving players a one-stop shop for viewing all things achievements.
Inside this tab, the summaries give the player a high-level view of how they're doing in your game. But players can dive deeper, scanning through the achievements they've already collected as well as previewing the ones they're working on and some others you've got in store for them. While the player can reach this page from the Dashboard, you can also present it directly with API. Doing so is done using the GKGameCenterViewController.
You can initialize it with an "achievements" state and optionally assign the gameCenter Delegate property on the view controller. With just these few lines of code, you'll guide players into the all-new achievements page for your game. This UI provides a clean and consistent window into your game's achievements, so it will be the preferred experience for the vast majority of games.
For those that need to customize their achievements' display in their own UI, this can be done using the GKAchievementDescription class. Like GKAchievement, which is what you use to update the player's progress, this class has an identifier. But it also has the "achievements" title, as well as separate descriptions for when the achievement is unachieved and achieved.
It's important to note that the title and descriptions associated with this class are localized according to the player's localization preferences. As the game developer, you will make sure that all the relevant translations are included when you set up an achievement in App Store Connect. But when interacting with the achievement descriptions, GameKit will give you strings that are ready to display to the player. And finally, there are also APIs for accessing achievement images for the achieved and non-achieved cases.
So we've talked a bit about how to design achievements that work well for your game. We've also shown how to work with GameKit to view and update players' progress. But before you can submit an achievements-ready build of your game to the App Store, you'll need to configure the achievements in App Store Connect.
To do so, go to the Features tab of your game's page on App Store Connect. Then, after selecting the Game Center section, you'll see an Achievements section. To add an achievement for your game, you can click the "plus" button. This will bring up the Add Achievement screen. The achievement ID must be unique to this achievement, and, as you saw in the previous code sample, is used to initialize your GKAchievement object.
You'll also have to configure a few attributes, such as point value, whether it's hidden until achieved, and whether the player can earn the achievement multiple times. These values will be reflected in the GKAchievement class we discussed earlier in the session. We can finish adding this achievement, and after we're done, our build is ready to deliver to users. Now I'm going to hand it over to Christy to talk about multiplayer gaming.
Thank you, Dersu. I am back to talk about multiplayer gaming using Game Center. First, I will give a quick overview of Multiplayer. Then I will show our new streamlined UI. Next, I will give a quick review of our basic API flows and introduce some new options for the Matchmaking UI. Finally, I will talk about some changes to privacy and restrictions. We support several types of multiplayer games: real-time, turn-based and server-hosted. The basic idea of our APIs is that we take care of as much of the multiplayer as we can for you.
For real-time, we take care of finding players, connecting to them, and sending data. For turn-based, we take care of turn management and storing the data. For server-hosted, we deliver you a list of players that you can share with your server. We have various ways to find people to play with. Firstly, we have a really robust auto-match system where we can find players and get you into the game fast.
All you have to do is hit "Start Game." You can also invite other players. We have made it super easy to interact with people you have made friends with. We also make it fast to find someone you just played with so you can play with them again, even in a different game. We want you to play with whomever you want, so you can invite from your contacts. This is great for developers to bring new players into the game. And finally, we work cross-platform, so your players can play multiplayer on whatever platform they like.
As you've just seen, there's a new streamlined UI. This is designed to help your users find other players quickly and get into the game faster. We did this by simplifying the flow and providing improved player suggestions. But why talk about it when we can show you? Here we tap on the multiplayer button and it brings up our matchmaking UI. Now we tap "Add Player"... and we'll invite our friend JonB. Next... we'll click on the "plus" button to bring up contacts and invite Vance.
Now we tap "Invite and Start Game"... and the last player will be auto-match. So that's how you set up a multiplayer game using our new flow. What does matchmaking look like from a coding perspective? Let's take a look at the elements of a real-time multiplayer match. Starting from MyGameController, first I authenticate the player, create a match request, and this is where I set the number of players in a match, and I can define people to invite.
it could be a friend, another person I recently played with, or someone discovered nearby. And if appropriate, I can use player groups and attributes to filter the match request to a specific game mode or other criteria. Now I have a choice: either to use this request for auto-matching or to present a UI for the player to select other people to invite.
So, let's say I'm doing auto-matching. Then I'd simply use the shared GKMatchmaker and provide it with my match request. Game Center will find other players. It's time to play, and you'll use the returned match object to send data from player to player. Or, as I said, I could choose to present a GKMatchmakerViewController, given the match request parameters, and let the player select their own people to invite. Once they've accepted, the game can begin.
One more piece, very important, which typically should be done right at app launch, is to adopt the GKInviteEventListener protocol... register it with the local player in order to listen for invites coming from other people, and now everything is ready to get started. Turn-based matchmaking follows virtually the same flow. Like in this case, you adopt a GKTurnBasedEventListener with a couple more methods to implement it and, like before, register it with the local player.
Then you set up a match request and call findMatchForRequest on the GKTurnBasedMatch for programmatic matchmaking. Or you present a GKTurnBasedMatchmakerViewController. Either way, an important difference with turn-based is that you do not wait for other players to match, but instead start playing immediately because it'll always be your turn.
For iOS 14, we have new options to configure the matchmaking UI. You can set "auto-match only" if you want players to match up with random other players and get quickly into the game. You can choose "nearby only" for games like ARKit games, where you wish to have players that are in the same room with you.
There is a new restriction this year that when enabled restricts both the custom message in multiplayer invites as well as voice chat. Here is a new flag, personalizedCommunicationRestricted, that lets the app know this so they can, for example, turn off their voice chat UI. So if your app shows a little microphone for voice chat, and if this flag comes back true, then disable the icon for this functionality.
In closing, I've talked about the different types of multiplayer, ways to find players, and gave you a glimpse of the new UI. Then I did a quick API review and introduced you to new UI options for our matchmaker view controller. And finally, I discussed a new privacy restriction. So that's our session on Game Center. Here we've covered leaderboards, achievements, and multiplayer. Here are some resources to check out for more depth. You can also see our design talk for more information. So thank you, and have a great WWDC.