Unity — new input system create an action map

Daniel Kirwan
4 min readJan 31, 2022

--

Objective: Create an action map in the new Unity input system

If you have already followed my previous article about installing the new Unity input system or you have done that yourself already and need to know how to start using the new Unity input system, then let’s crack on.

What you want to do in your project files is create an input action. Right-click -> create and select input actions.

Then rename the asset to that of your choosing, DO NOT call the asset PlayerActions. If you do this it will cause issues as their are Actions inside the asset that utilise that name. I called mine, PlayerInputActions.

Once it has been named you can double-click the asset and it will open a new window, dock the window so that you can see everything you need to.

You can create different action maps here for different styles of controls, so if you have player movement and vehicle movement this is where you can create those different controls.

I created a basic Player action map as my game is 2D. Creating the action map will auto generate an action. I usually delete the auto generated action as I want to create my own. In the action section click on the Plus icon. This will let you name your action. I named my first one Movement. Before you click the plus button you will need to set the action type and the control type.

On the new Movement action I needed to add a binding. For my game I want the player to be able to use the keyboard or a controller joystick.

I created two bindings, 1 called Keyboard and 1 called Controller. The binding I needed to use for my 2D movement was a 2D vector composite.

You will want to make sure that the composite mode is set to digital normalised.

Once you select the composite you should get options for 4 bindings that you need to assign either the keys or the joystick.

I then followed the same process for my next action for the player which is to be able to fire. For this I made the action type a button and then selected the buttons I want the player to be able to press.

You can see above that I have selected the Space key or the A button on a Xbox controller or the Cross(X) button on a PS4 controller.

And that is it for starting my action map. This will allow me to move and fire. Make sure to check out the next article for how to use the action map in your code to move and fire.

The last thing before we can start to move and fire we need to generate a C# script for the input actions. Click on the input actions asset in the project window, the tick the box for generating a C# script then click apply.

If you found this helpful, don’t forget to clap and follow for more articles on game development in Unity.

--

--