Blog

Controllers

Nintendo Switch

SwitchControlDiagram

xBox360

xBox360ControlDiagram

PS4

ps4ControlDiagram.png

Advertisements

Setting up 2 players

Hurry Hurry Heal Me would be no fun if it was only 1 player, so I now need to make sure that I can have 2 controllers moving 2 separate players.

Screen Recording The Process

The Input Manager

Edit > Project Settings > Input

Is where most of the magic takes place. But before we start adding in inputs it is useful to know a little about how Unity keeps track of different controllers.

Input.GetJoystickNames

Is the function needed to know which Joystick Unity has mapped to the Joy Num. Now Input.GetJoystickNames is actually a string with all the information (names) of the controllers that Unity can see, but this is not the Joy Num. The Joy Num is the number that the controller appears in the GetJoystickName list (array). So to find this out, you need to run a little function.

screen-shot-2017-02-15-at-13-53-38

This function returns something like this in the Debug Console. I was able to tell which was the ps4 controller and the xBo350 controller by plugging them in one at a time.

Showing that:

  • 47 = joystick 1
  • 32 = joystick 2

Screen Shot 2017-02-15 at 13.54.32.png

Player Movement Script

A few changes need to be made to the player movement script as I now want to specify which controller I want to use (rather than taking any input I give it).

I add a public string = controller;

screen-shot-2017-02-15-at-14-00-09

This allows me to type into Unity the controller I am using for that player.

screen-shot-2017-02-15-at-14-00-51

I now need to change the string I used to get the input to include my controller sting

screen-shot-2017-02-15-at-14-00-30

screen-shot-2017-02-15-at-14-00-36

So now my FixedUpdate looks something like this:

  • I have added “X” , “Y”, “Run” to the end of the controller string as I have different inputs for each of these variables, which needs to be mapped in the Input Manager.

screen-shot-2017-02-15-at-14-00-16

Back to the Input Manager

Now that we can distinguish the controls for the two players, we need to show this in the input manager.

  • This means creating a load of xBox360 inputs and ps4 inputs.
  • As we know which controller is which JoyStick number we can add it here as well
  • If you have buttons you need to make sure you specify which JoyStick you are using as well.
  • Note that I could have called xBox360 anything as long as under the controller String I have called it the same.

Setting up Character Movement

So what to do next? Well, better start making some of the game mechanics. I think the most basic one to start with is character movement, so lets start with that one!

Check out the Screen Recording of this Process

 

Character Movement in Unity

Step 1

Creating the GameObjects

  • Create a player character  (the cube)
  • Create a ground (a plane)

Screen Shot 2017-02-14 at 10.20.30.png

Step 2

Adding player things to the player

  • Rigidbody

screen-shot-2017-02-14-at-10-22-30

 

Step 3

Adding a playerMovement Script

Screen Shot 2017-02-14 at 10.23.30.png

 

Step 4

The code for the player movement script. Here I’m going to be moving the player using forces. The walkSpeed is a public value so I can quickly change it later in Unity.

screen-shot-2017-02-14-at-10-26-27

Step 5

The sprint…

  • I add in another public variable called runSpeed. 
  • I then add in a check to see if a button is being pressed (I shall show you how to do this with the xBox controller config bit).
  • There is also an if statement to check which speed to use – depending on which button is being pressed.

Screen Shot 2017-02-14 at 10.26.58.png

Step 6

The Jump…

  • Is a new c# script
  • It has a public variable jumpVelocity
  • It checks if a button is being pressed
  • Creates a new Vector 3
  • And with an if statement checks if that jump button is being pressed to AddForce to the player.

The only problem with this script is that the player does not land…

Screen Shot 2017-02-14 at 10.32.00.png

Step 7

Adding a limit to the jump – so it looks like a jump rather than a jet pack.

  • I have added a public variable grounded which checks if the player is ‘on the ground’ or not. This is public for debugging purposes as Unity shows you a tick box, indicating true/false.
  • My if statement now checks 2 things:
    • If the jumpButton is down
    • If the player is grounded.
  •  To change the state of grounded I have added in 2 more functions
    • OnTriggerEnter
    • OnTriggerExit
  • In these functions we check if the player (other) has collided with a GameObject with the Tag: Ground
  • If the player is touching ground – grounded = true
  • If the player is not touching ground – grounded = false

Screen Shot 2017-02-14 at 10.35.06.png

Step 8

Adding the right information to Ground

  • Back in Unity click on your Ground and look at the inspector.
  • Ground needs the Tag: Ground (I added a new tag for this)
  • The Box collider on the Ground needs to be a trigger

Screen Shot 2017-02-14 at 10.42.05.png

Step 9

Attach your scripts to the player

  • AddComponent to the Player
  • Add Scripts
  • Choose to add the scripts you just wrote
    • Player Jump
    • Player Movement

 

Step 10

Checking the right information is on the Player

  • The collider is currently not a trigger
  • The Rigidbody uses gravity
  • You should now see your scripts at the bottom as well
    • You can now add in some values for: Walk Speed, Run Speed and Jump Velocity.

Screen Shot 2017-02-14 at 10.43.52.png

Step 11

At the moment I don’t want my player to rotate everywhere so I added in a FreezeRotation into the constraints.  But I will later change this so that the right joystick pad controls the rotation of the player.

Screen Shot 2017-02-14 at 11.02.44.png

Step 12

This is what my unity looks like at the end of doing these steps…

screen-shot-2017-02-14-at-10-17-47

 

Using an Xbox Controller for Movement

I am developing on a mac and there are no offical drivers for xBox 360 controllers but this one is very good: https://github.com/360Controller

Step 1

You can download it from here: https://github.com/360Controller/360Controller/releases.

Step 2

To check that it is all working go to System Preferences and it should appear down the bottom.

screen-shot-2017-02-14-at-10-52-01

By clicking on it you are given a window where you can see if the computer is receiving inputs from the controller.

screen-shot-2017-02-14-at-10-52-10

 

Step 3

Go to Unity and Edit -> Project Settings -> Input to bring up the Input manager.

screen-shot-2017-02-14-at-10-54-03

The Input Manager is where you can change the Inputs, for example to use the joystick controls rather than the keyboard ones.

screen-shot-2017-02-14-at-10-54-17

Step 4

I want to change the Horizontal and Vertical  controls to be on the left joypad.

  • So I select Type at the bottom and choose Joystick Axis
  • Axis X or Axis Y depending on if it is the horizontal / vertical input

 

Step 5

I want to use a joyStick button for the run and jump.

 

 

 

 

 

Development Time Line

A very productive Monday morning

We worked out a couple of key milestones for developing Hurry Hurry Heal Me if we wanted a working demo by the 1st June.

We decided to use an agile working method so that by the end of each week we have an Minimum Viable Product (MVP) which means working on the code and art simultaneously, compared to doing all the code first and then the assets.

Hopefully this means that we can post lovely development photos and videos for everyone to see!

 

Setting up a Landing Page

Designing

First things first is designing a landing page, check out our YouTube video showing a screen recording of how this was done.

 

There are 4 different designs for the website depending on which size you are viewing it at: phone, tablet, laptop, desktop.

Illustrator Designs

 

Coding

These designs now needed turning into code, marking up the text in html then styling using css, you can check out our other process video.

 

We started with a https://html5boilerplate.com/ to work on top of to help ensure the same experience across different browsers. In the CSS there are 4 different breakpoints for each of the four designs.

 

Hosting the website

In order make the website live we needed to host it somewhere and have a nice domain name. We used GoDaddy for the domain name provider and AWS to host the static website using S3 (part of the free tier) and Route 53 (about 50p per website).

 

What is S3?

Amazon Simple Storage Service is storage for the Internet, you can use S3 to store and retrieve any amount of data, at any time, from anywhere on the web.

Setting up S3

This is going to store your landing page, for everyone to see.

Step 1

Log into the AWS Services and go to S3

screen-shot-2017-02-07-at-09-59-03

Step 2

Create a Bucket

screen-shot-2017-02-07-at-09-59-20

Step 3

Name your bucket and choose a region that you want it to be stored. As most of our traffic will be UK based we selected our region to be London.

Note about naming: a bucket name is unique to the amazon server and if you are hosting a website it needs to be exactly the same as your domain name – hurryhurryhealme.com

It is also useful to create another bucket called http://www.hurryhurryhealme.com

screen-shot-2017-02-07-at-09-59-28

Step 4

The permissions need to be changed through the edit bucket policy.

Screen Shot 2017-02-07 at 09.59.48.png

 

Change the bucket policy to…

{
“Version”: “2012-10-17”,
“Statement”: [
{
“Sid”: “AddPerm”,
“Effect”: “Allow”,
“Principal”: “*”,
“Action”: “s3:GetObject”,
“Resource”: “arn:aws:s3:::hurryhurryhealme.com/*”
}
]
}

screen-shot-2017-02-07-at-09-59-53

Step 5

Static Web hosting needs to be enabled and you can choose which index document and error document you like.

screen-shot-2017-02-07-at-10-00-10

Step 6

Make a second bucket and call it http://www.hurryhurryhealme.com so that traffic that searches for www. and just the url will be directed to the same site.

The Static Website Hosting for this one is slightly different – as you want to redirect all requests to this bucket to your other bucket.

Screen Shot 2017-02-07 at 10.09.38.png

 

Step 7

You can check that your website is working by copying and pasting the Endpoint url.

 

Setting up Route 53

 

 What is Route 53?

Amazon Route 53 is a Domain Name System (DNS) web service. It is designed to route end users to Internet applications by translating names like http://www.example.com into the numeric IP addresses like 192.0.2.1 that computers use to connect to each other.

 

Setting up Route 53

This is going to direct anyone who types in your domain name to your aws bucket.

Step 1

Log into the AWS Services and go to Route 53

screen-shot-2017-02-07-at-09-59-03

 

Step 2

Go to your hosted zones tab on the left.

screen-shot-2017-02-07-at-10-17-43

Step 3

Click on Create Hosted Zone

screen-shot-2017-02-07-at-10-17-51

Step 4

Enter your domain name (this should be the same as what you called your S3 bucket, e.g. hurryhurryhealme.com, keep it as a public hosted zone.

screen-shot-2017-02-07-at-10-17-57

Step 5

You can now create a Record Set. 

screen-shot-2017-02-07-at-10-18-23

Step 6

You want to:

  • Name: leave blank
  • Type: A
  • Alias: Yes
  • Target: your S3 website endpoints from the drop down list.

screen-shot-2017-02-07-at-10-18-35

Step 7

Create another Record Set.

Screen Shot 2017-02-07 at 10.26.47.png

Step 8

Your hosted zone should now look like this!

screen-shot-2017-02-07-at-10-18-14

 

Domain Name

Now you want a nice domain name for people to type in and access your website, I’m going to talk about the process with GoDaddy.

 

Step 1

Register a Domain Name – Buy one!

 

Step 2

Got to Manage My Domains

screen-shot-2017-02-07-at-10-31-31

Step 3

Find your domain name and go to Manage DNS by clicking on the little cog.

screen-shot-2017-02-07-at-10-31-52

Step 4

Go to your named servers and change them.

You want to name the servers the same as the ones on your Route 53.

 

Step 5

Now wait – for .com names it will take up to 24hours and for other’s it could take up to 48hours.

Keep checking to see if your website is up by typing in your url: hurryhurryhealme.com

 

Google Console

To make sure that people can search for HurryHurryHealMe.com there is one last thing to do, tell google that you own the site.

screen-shot-2017-02-07-at-10-40-03

Step 1

Click on Add a Property 

screen-shot-2017-02-07-at-10-40-16

Step 2

Type in your website

screen-shot-2017-02-07-at-10-40-34

Step 3

You are then asked to verify your website, download the google file.

screen-shot-2017-02-07-at-10-40-42

Step 4

Then upload it to your S3 bucket.

screen-shot-2017-02-07-at-10-41-41

Step 5

You can now verify your site

screen-shot-2017-02-07-at-10-42-04

Step 6

You can also do this process again for the website name with www. in front. You wont need to upload the file again as it is already in your bucket.

screen-shot-2017-02-07-at-10-42-40

Step 7

You can now check that this works by going to google and searching for the site. Sometimes it takes a little while for this to happen to!

Screen Shot 2017-02-07 at 10.47.23.png

 

One fully working landing site

All done!

 

Social Media

It has been said that for a successful indie game you need a good social media presence. So we decided to start up some key social media accounts.

The Social Media Accounts

 

The Hash Tag

For a little background research we looked into which tags are best to use, following the advice of https://ritetag.com/.

There are also a couple of hash tag events throughout the week on Twitter such as:

  • Tip Tuesday
  • Indie Dev Hour
  • Screen Shot Saturday

 

Finally Hash Tags should be used wisely – no more than 3 to a post!

 

The Posts

The time, length and content of a post is important and differs for each social media account. For example tweets should go out between 1pm-4pm and Pintrest posts should happen between 8pm-1am.

 

Setting up a collaborative unity environment

The Beginning

We are two games designers who want to work on the same Unity file, each editing code and art work. Here I am going to explain how we set up an environment to do this:

Step 1

Following this tutorial we set up our first source controlled repository.

This means that all our source code is stored in the cloud so that both us can access it at any time. It also has a version history, so that we can rewind time if things break and see who has worked on things when.

Bitbucket is free for 5 or less users letting us keep all the code private, we could also have stored the information publicly on github – but seeing as the tutorial was good for bitbucket it seemed a shame not to use it.

The tutorial shows you how to use SourceTree which is a graphical representation of using Git through Terminal. By using SourceTree it makes the process a little more apparent for  first time source control users.

Step 2

Inviting your team member(s) to your bitbucket project. They will receive an email that allows them to access the code.

screen-shot-2017-02-01-at-13-38-46-copy

Step 3

Clone the repository using SourceTree onto the other persons computer. Choosing a folder to put the code into on their desktop.

Screen Shot 2017-02-01 at 13.41.57 copy.png

Step 4

Check everything in SourceTree. They might need to pull the code.

Screen Shot 2017-02-01 at 13.44.42.png

Step 5

They can then open the unity project and check it is working

Screen Shot 2017-02-01 at 13.46.43.png

Step 6

If they make a change in Unity, save and then go back to SourceTree. They should now have files that need to be staged -> committed -> pushed.

For more information on the process check out this tutorial.

You do not need to stage any: Library or Temp files.

Step 7

You can now go back to your computer and check SourceTree and if you need to pull any of their files. For further reading on source code control check out the Git Documentation.

You have now set up a collaborative unity environment where you can share information between a small team!

Screen Shot 2017-02-01 at 13.59.57.png