Giter Club home page Giter Club logo

amazon-gamelift-ultrafrogroyale-large-match-sample's Introduction

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

  1. Open the project in Unity
  2. 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
  3. Add the AWS Mobile SDK for Unity to the project. https://docs.aws.amazon.com/mobile/sdkforunity/developerguide/what-is-unity-plugin.html
  4. 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

  1. Make sure you have the latest AWS command line installed.
  2. 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

  1. 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
  2. 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.
  3. Create matchmaking ruleset using the file AWS/UltraFrogRoyaleFreeForAll-debug_MatchmakingRuleSet.json
    • Use us-east-1 region as this is hardcoded in the demo
  4. 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.

amazon-gamelift-ultrafrogroyale-large-match-sample's People

Contributors

alanmur avatar amazongametech avatar jamesiri avatar squidbot avatar xmiao2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

amazon-gamelift-ultrafrogroyale-large-match-sample's Issues

Sample uses authors Cognito unauth role without cross-account access to invoke a Lambda in the customer's account

We need to add instructions on how to create a Cognito Identity Pool in the user's account so the unauthenticated player can invoke the client service Lambda. Presently we get:

Amazon.Lambda.AmazonLambdaException: User: arn:aws:sts::768788344492:assumed-role/Cognito_UltraFrogBattleRoyaleAnonPoolUnauth_Role/CognitoIdentityCredentials is not authorized to perform: lambda:InvokeFunction on resource: arn:aws:lambda:us-east-1:768788344492:function:ConnectUltraFrogRoyaleClient ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.
at Amazon.Runtime.Internal.UnityRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x0000e] in <63c2de57b2a5496ca21edbdf1b5cf408>:0
at Amazon.Runtime.Internal.HttpHandler1[TRequestContent].GetResponseCallbackHelper (System.Object state) [0x00023] in <63c2de57b2a5496ca21edbdf1b5cf408>:0 --- End of inner exception stack trace --- at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException (Amazon.Runtime.IExecutionContext executionContext, Amazon.Runtime.Internal.HttpErrorResponseException exception) [0x0013f] in <63c2de57b2a5496ca21edbdf1b5cf408>:0 at Amazon.Runtime.Internal.ExceptionHandler1[T].Handle (Amazon.Runtime.IExecutionContext executionContext, System.Exception exception) [0x00000] in <63c2de57b2a5496ca21edbdf1b5cf408>:0
at Amazon.Runtime.Internal.ErrorHandler.ProcessException (Amazon.Runtime.IExecutionContext executionContext, System.Exception exception) [0x0005c] in <63c2de57b2a5496ca21edbdf1b5cf408>:0
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsyncCallback (Amazon.Runtime.IAsyncExecutionContext executionContext) [0x0002f] in <63c2de57b2a5496ca21edbdf1b5cf408>:0

Calling Lambda function for matchmaking yields an error

I followed the tutorial of the project and all went well until i tried to connect the client to the server. So when i try to run the client and press join match it will keep trying to connect to matchmaking using the lambda function and after the timeout period which is around 80 seconds it yields the following :
Function Error : Unhandled
Status code : 200
Payload : {"errorMessage":"2021-05-19T21:53:42.999Z bf608fda-5ea5-4bf4-a72f-e2b07021aca6 Task timed out after 80.08 seconds"}
For replicating it just follow the exact as the tutorial.
The same error happens when i try to test the lambda function from AWS console so i don't think it's a unity issue.

Matchmaking ticket is in PLACING status and cannot be canceled.

Hi Team, we've followed all the steps as per documentation to run the sample. But now we're facing an error in lambda of matchmaking failed. I'm attaching the screenshot of the error as well.

Error is like:

Error in Lambda assume matchmaking failed: {"message":"Matchmaking ticket is in PLACING status and cannot be canceled.","code":"InvalidRequestException","time":"2020-01-17T12:21:17.325Z","requestId":"499c4016-e005-4aa4-a164-b54cbbcb558c","statusCode":400,"retryable":false,"retryDelay":48.43038812741705}

UnityEngine.Debug:Log(Object)
GameNetworkManager:<FindMatch>b__12_0(AmazonServiceResult`2) (at 
Assets/GameNetworkManager.cs:154)
Amazon.Lambda.<>c__DisplayClass41_0:<InvokeAsync>b__0(AmazonWebServiceRequest, 
AmazonWebServiceResponse, Exception, AsyncOptions)
Amazon.Runtime.Internal.UnityMainThreadDispatcher:ProcessRequests()
Amazon.Runtime.Internal.UnityMainThreadDispatcher:Update()

image

Please help me out of it if you can. Thanks.

Is this best practice?

console.log("describeMatchmaking attempt #" + attempts);

According to AWS documentation, describeMatchmaking() is not meant to be continuously polled: https://docs.aws.amazon.com/gamelift/latest/apireference/API_DescribeMatchmaking.html

"This operation is not designed to be continually called to track matchmaking ticket status. This practice can cause you to exceed your API limit, which results in errors. Instead, as a best practice, set up an Amazon Simple Notification Service to receive notifications, and provide the topic ARN in the matchmaking configuration. Continuously poling ticket status with DescribeMatchmaking should only be used for games in development with low matchmaking usage."

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.