How to gather player feedback from your Unity game using AWS

Using the AWS SDK in Unity

AWS can be daunting!
What we’ll be building

Let’s get started!

First off, you’ll need to make an AWS account, if you don’t already have one. Note that using SNS may incur some charges, but your first 1000 emails per month are free, so unless you’re getting a huge amount of player feedback you’re unlikely to pay anything.

Make an SNS topic

Now that we’re in the SNS dashboard, click “Topics” in the menu on the left and click the button that says “Create topic”. Give it a name like “PlayerFeedback” and a “Display name” of your choice (the display name will also show up as the “sender” of the feedback email). You can leave everything else the same, but take a look at the “Access policy” settings. By default, only the topic owner (your AWS account) is allowed to publish messages to this topic. In the next section we’ll make it so your Unity game can publish messages to it as well.

The SNS topics page

Subscribe your email to your topic

After creating your topic, navigate to its details page and click “Create subscription”. On this page, the “topic ARN” should be the Amazon Resource Name of the topic you just created (it should be auto-filled, but if not then clicking in the field should give you a list to choose from). Pretty much every resource in AWS has an ARN, which is just Amazon’s internal identifier for that resource. It can act as an ID, but in some situations you can also use them sort of like paths with wildcards to identify groups of resources.

IAM Confused

You already have an AWS user, your root user. That’s the one you signed up for AWS with and that you use to log in to the web console. This user has admin access to everything in your AWS account. In the past, you could have access keys attached to this user and use those keys to do AWS things from your code, but that’s really insecure because you’d be giving admin access to your code (and anyone who could find the keys)! Since we want to let our game have AWS access, and then distribute the game all over the place, this is definitely not an option.

Create an IAM User

Now that we know what we’re doing, go to the AWS “Services” dropdown again, and this time find IAM. From the IAM menu, go to “Users” and then click “Add user”. Give the user a name like “feedback-sender”, select that you want it to have “Programmatic access”, and just click “Next” through all the remaining screens — we’ll attach a policy in a minute!

Give our IAM user permissions to our topic

Now go back to the IAM users section. Click the user you just created, and in the “Permissions” tab you should see a link on the right that says “Add inline policy”. An inline policy is one that’s attached to the user object itself, so it will be easy to find and manage. If we wanted to reuse the policy with multiple users we could create a full one, but for our purposes an inline one is less clutter.

Create an inline policy
Setting up your policy
{
“Version”: “2012–10–17”,
“Statement”: [
{
“Sid”: “VisualEditor0”,
“Effect”: “Allow”,
“Action”: “sns:Publish”,
“Resource”: “arn:aws:sns:us-west-2:0123456789:PlayerFeedback”
}
]
}

Make some feedback UI in our game

That’s it for the AWS side of things! Now we need to make some UI that lets the user type in some feedback. Like I said above, I’m assuming you know the basics of Unity, so I won’t go into much detail here. I just made a simple panel with a text field, an error label we can show if anything goes wrong, and some buttons. I can show the feedback form in-game by setting its game object to be active, and then it sits on top until the player sends or cancels.

Example feedback UI

Add the AWS SDK to Unity

Okay, now we need to write code in our game to let users send feedback. To help with this, Amazon provides a .NET SDK that lets us work with AWS. The AWS SDK is split into pieces depending on which AWS services you want to use.

  1. Download the package from NuGet
  2. Rename the file to have a .zip extension
  3. Unzip it
  4. Find the .dll in the lib/netstandard2.0 folder
  5. Copy/paste the .dll to somewhere in your Unity Assets folder

Let’s hook it up!

Hopefully you survived the above and now we’re ready to write some code. Here’s an example MonoBehaviour you can add to your feedback form (this uses TextMeshPro which is bundled with Unity, but you could easily edit it for whatever you’re using):

https://gist.github.com/all-iver/acc21dd0df9b9baeb57c253ffb58f615
  1. Add it as a component to your feedback UI’s GameObject in the Unity inspector
  2. Wire up your input text field, error message label, and send/cancel buttons to the corresponding fields in the component
  3. Fill out your SNS details (you can find your region code in your SNS topic ARN)
  4. In the Unity inspector, have your buttons’ OnClick() handlers point to FeedbackUI’s OnClickSend() and OnClickCancel() methods
  5. When you want to show the form, just do something like feedbackUI.gameObject.SetActive(true). In my game, I have a small button at the bottom right of the screen that players can click at any time.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Oliver Smith

I’m making a video game about space farming in Portland, OR. Check me out at https://www.jellygon.com or @all_iver on twitter!