In this tutorial I am going to show you the Nakama specific parts to build some social and competitive features for a fictional Unity game inspired by the hit mobile game, Crossy Road. Nakama is a customizable and scalable open source game server with all the social, competitive, and economy features you need to build and scale online games.
Next install the Nakama Unity SDK, and in your main scene connect your game to your Nakama server by creating a Nakama Client.
Now that your game is connected to the server, it’s time to authenticate players with Facebook, import their Facebook friends, create game sessions and manage user accounts.
Authenticating with Facebook is simple with Nakama:
Your friends can easily be imported by passing a
True value for
importFriends. Nakama will then add them to your in-game friends list if they are also playing.
Once authenticated, sessions can be restored or refreshed so that players don’t have to re-authenticate. The session auth and refresh tokens can be stored in Unity’s
Then accessed to restore sessions:
Or refresh sessions before they expire:
Using the session we can get the current player’s user account, and access and update properties, visualized in your game’s profile screen:
Nakama has many more easy-to-use APIs for working with friends, groups (clans), real-time parties, matches, leaderboards, chat and more.
Nakama makes it easy to add social and competitive features to singleplayer games or build complete real-time multiplayer experiences. Like Crossy Road, the core gameplay of Croaky Road happens on the client and players compete against each other on global or friend leaderboards.
Once players complete a round and receive a score we’ll show them where they ranked versus their friends.
Player scores can be submitted to the leaderboard and Nakama will take care of ranking and ordering players.
Nakama has powerful leaderboard listing functionality. We could display the top records on the leaderboard, records around the player, the player’s group (clan) and for this example just the player’s friends:
Nakama comes with a developer console for monitoring your game server config, users, storage, matches, leaderboards and performance.
This is just a taste of how easy it is to add social and competitive features to your game. Nakama also has a wealth of realtime multiplayer features for matchmaking, networking game state and so much more.