amazon-gamelift-largematch-sample-ultrafrogroyale
A small game built with Unity to demonstrate how to use the new Amazon GameLift large match features.
Disclaimer
This project references AWS Mobile SDK for Unity which has been deprecated in favor of AWS SDK for .NET. Until it is updated, please refer to the aws-gamelift-and-serverless-backend-sample repository to find instructions on how to setup and build AWS SDK for .NET.
Requirements
Contents
├── AWS # Lambda functions, IAM policies, rulesets, etc.
└── UltraFrogRoyale # The root of the Unity project
├── Assets # Editable assets, source files
│ ├── Scenes # Unity scene definition files
│ ├── Prefabs # Player prefab for networking
│ └── Textures # Images used by the game
├── Packages # Unity packages folder
└── ProjectSettings # Unity project folder
Building and using the sample
Step 1: Build the Unity project
- Open the project in Unity
- Build and add the Amazon GameLift Server SDK to the project following the instructions here (specifically for .Net 4.5): https://docs.aws.amazon.com/gamelift/latest/developerguide/integration-engines-unity-using.html
- Add the AWS Mobile SDK for Unity to the project. https://docs.aws.amazon.com/mobile/sdkforunity/developerguide/what-is-unity-plugin.html
- Create a client and server build from Unity. A server build can be created by selecting "Server Build" from the Build Settings dialog.
Step 2: Upload server build to GameLift
- Make sure you have the latest AWS command line installed.
- Upload the server build to GameLift
- Use us-east-1 region as this is hardcoded in the demo
- Example command:
aws gamelift upload-build --operating-system WINDOWS_2012 --build-root "C:\amazon-gamelift-largematch-sample-ultrafrogroyale\UltraFrogRoyale\ServerBuild" --name "UltraFrogRoyale" --build-version "build 1" --region us-east-1
Step 3: Prepare GameLift
- Create a new fleet
- Use us-east-1 region as this is hardcoded in the demo
- Select the build uploaded in step 2.
- c5.large works well and is in the free tier
- Fleet type: On-Demand
- Binary type: Build
- Set the launch configuration to call "UltraFrogBattleRoyale.exe" with 1 concurrent process
- Add port range 7000-8000, protocol UDP, IP address range 0.0.0.0/0
- Add port range 7000-8000, protocol TCP, IP address range 0.0.0.0/0
- Don't set a scaling policy on the fleet
- Create a game session placement queue
- Use us-east-1 region as this is hardcoded in the demo
- Adding the fleet just created as the only destination.
- Create matchmaking ruleset using the file AWS/UltraFrogRoyaleFreeForAll-debug_MatchmakingRuleSet.json
- Use us-east-1 region as this is hardcoded in the demo
- Create matchmaking configuration
- Use us-east-1 region as this is hardcoded in the demo
- Matchmaking configuration must be named "UltraFrogRoyaleMatching" so the Lambda can invoke it
- Use the ruleset and queues you just created
- Ensure "acceptance required" is set to "no"
Step 4: Create client service
Refer to the instructions found in step 2 of the article https://aws.amazon.com/blogs/gametech/creating-servers-for-multiplayer-mobile-games-with-amazon-gamelift/ with the following differences:
- Call the Lambda ConnectUltraFrogRoyaleClient
- Select node.js Lambda runtime
- Set the Lambda IAM role using the rules found in AWS/ConnectUltraFrogRoyaleClient_LambdaIAMRole.json (this differs from step 15-17, you can skip the action editor and just paste in the json)
- Use the Lambda source code found in AWS/ConnectUltraFrogRoyaleClient_Lambda.js
Step 5: Run the game
At this point, you'll be able to run the game client and hit the "Start A Match" button. Note that the way the matchmaking rules are configured, you'll need to connect at least 3 clients before you get a match. You can run these clients on the same machine.
For more information or questions
License Summary
This sample code is made available under the Apache-2.0 license. See the LICENSE file.