A sample game demonstrating the use of Google Play technologies on Android with Unreal Engine.
This version of TrivialKart demonstrates:
- Play Games Services (v2): For sign-in, achievements.
- In-App Purchases (IAP).
- Unreal Engine: Version 5.4 or higher (Recommended).
- Android Studio: Properly configured for the specific version of Unreal Engine being used.
- Google Play Games Unreal Plugin: Ensure the official plugin is enabled.
- Google Play developer account.
- A configured project in the Google Play Console.
- Clone the repository and navigate to
trivialkart/trivialkart_unreal. - Right-click
TrivialKart.uprojectand select Generate Visual Studio project files. - Open the
.slnfile in Visual Studio (or the.uprojectin Unreal Editor). - Open the
L_TrivialKartfound inContent/Maps.
By default, Google Play features are simulated or disabled unless the Google Play plugin is active and configured with a valid App ID.
In TrivialKart, the player has a vehicle which they can drive by tapping on it. Driving the car uses gas. When the car runs out of gas, to continue driving, more must be purchased using in-game currency. If the player runs out of in-game currency, they may buy more via in-app purchases. In-game currency is an example of a consumable purchase that may be repeated.
The game has different cars available for unlock. One car is purchasable using in-game currency; other cars require unlocking via in-app purchase. These unlocks are permanent one-time purchases.
The game features:
- Consumable Purchases: Coin packs.
- Go to the Google Play Developer Console and create a new application.
- Navigate to
Monetise with Play -> Monetisation SetupCopy the Base64-encoded public key text in theLicensingarea. You will need to use this key when configuring IAP.
- In Unreal Editor, go to Project Settings > Platforms > Android.
- Under Google Play Services:
- Enable Support Google Play Services.
- Copy your License Key from the Play Console into the Google Play License Key field.
- Under Advanced APK Packaging, ensure your Package Name matches the Console.
Note: you must upload a build to Google Play to be able to create your in-app purchasing items in the Google Play Developer Console Console.
-
Return to the Google Play Developer Console.
-
Under
Monetize -> Products -> In-app products, create the following in-app products:Product ID Price five_coins $0.99 ten_coins $1.99 twenty_coints $2.49 fifty_coins $4.99 -
Publish your build to the testing channel. It may take up to a few hours to process the build. Running a build before processing complete can result in errors such as Google Play reporting that "this version of the application is not enabled for in-app billing".
-
Add tester accounts to your game. This will allow you to test purchases and subscriptions without being charged. Test accounts also have greatly reduced subscription periods, allowing for easier testing of subscription features.
- Go to the Google Play Developer Console and create a new application.
- Navigate to
Grow Users -> Play Games Services -> Setup and Management -> Configurations - Generate a Game server credentials by making a credential of type Web Application.
- Go to Google Play Services in Unreal Engine via
Project Settings -> Android -> Google Play Services - Copy your Crednetials from the Play Console into the Google Play Games Oauth Client ID Register for Game Server field.
In the Play Games Services section of your Play Console entry for your app, access the Achievements sections to add the following achievements:
Achievements
Name: tk_achievement_drive
Description: Drive a while
Initial State: Revealed
Incremental: Unchecked
Points: 5
Name: tk_achievement_fuel
Description: Empty the fuel tank
Initial State: Revealed
Incremental: Unchecked
Points: 5
Name: tk_achievement_login
Description: LogIn 5 times
Initial State: Revealed
Incremental: Checked
Points: 5
If you've found any errors or bugs in this sample game, please file an issue.
Assets provided by Kenney.nl under Creative Commons Zero.