Asteroids – Inputs

So we have a ship in our scene with some stats but how do we make it move?

Unity has something called an input manager. This input manager allows us to easily assign keys to do things in our game.

To open the input manager go to Edit > Project Settings > Input.

Opening the Input Manager

The inspector will change to something like this:

Input Manager in Inspector

Press the arrow next to Axes to expand the menu.

Axes Expanded

Notice how there are different names for inputs in a list. Names such as Horizontal, Vertical etc. This is the name and description for the input. If you select Vertical for example you will notice that the keys assigned to it are up and W for positive and down and S for negative.

Vertical Expanded

What does this mean?

It basically means when W is pressed a positive value is returned and when S is pressed a negative value is returned. These values are then used to apply an input to the game.

For example Vertical is often used for up and down, hence when W is pressed and a positive value is returned a game object will move upwards. When S is pressed the object will move downwards.

I will show you how to apply inputs to a GameObject in the next part. For now we will be adding an input. To do this change the size value underneath Axes by 1 (in mine it will go from 18 to 19)

Increasing Size

You should notice the input at the bottom of the list will be cloned. Select the new clone and change it’s name to SideWays. Make Q the negative button and E the positive button. Delete any “Alt” buttons and change the gravity and sensitivity to 3 (to match the Vertical and Horizontal inputs). We can always change these again later if we require. Also select the snap setting.

SideWays Setup

If you would like to know what each of these settings do then you can move the cursor over the name of the setting and a descriptive popup will appear. If you want more descriptions just let me know in the comments and I will do my best to explain.

The movement control scheme we will be using is:

  1. Vertical will move the ship forwards and backwards.
  2. SideWays will move the ship left and right.
  3. Horizontal will spin the ship.

We will implement it over the next two parts of this tutorial.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s