How to Make a Character Move in Unity’s New Input System

Justin Schverak
4 min readJul 23, 2022

--

Making a character move can become a big headache.

The new Input system allows us to edit controls more easily than in the old input system. Along with that, we can create more actions that allow us to have more key bindings.

Objective: To make a simple movement system with the new unity input system

To start, we’ll need to install the new input system package in the package manager.

After you install this, unity will require a restart.

Then, we’ll need to create the input settings. So let’s create a capsule with the Player input component.

The Player Input component will allow us to have inputs call to a function.

Next, we’ll need to edit our input settings to support a mouse and keyboard.

This will allow us to use our keyboard and mouse as inputs

Then, we need to create some actions so it reads our inputs.

After you create it, a menu will pop up like so:

This is where we could map new key bindings for specific actions.

Next, we’ll need to change the behavior of our player input component so that it calls public functions in a script.

This will allow us to call public functions.

Then, we’ll need to create a script, I’ll call mine Player.

Next, we need to create a public function called Movement with a InputAction paramenter.

The InputAction parameter allows a input action to call on this function.

Now, lets add a input action event on our Player Input component.

Now, we’ll need to add a private vector2 variable named _inputs and use it in our new Movement function.

This will capture our WASD inputs and read the Vector2 value that comes along with it. Let’s see what the _inputs variable is getting by using a debug statement.

This shows that everything is working as intended and shows us that the _inputs variable only updates once when a button is pressed.

Next, we’ll need to create another function called Move.

Then, we’ll need to get a vector3 direction from the inputs.

This will give us the direction the Player wants to move.

Now, we’ll create a vector3 velocity variable and a float speed variable and we’ll multiply the direction with speed.

Next, we need to add a character controller variable and use the move command.

This will move our character and the transformDirection command converts local space to world space so our character moves in the way it’s facing.

Next, we need to call the move function in our update function.

Finally, lets create the Character controller component and plug it in to our script

That’s it, by using the new input system, we can develop controls faster and easier.

--

--