Player Movement — Unity New Input System

Jack Leavey
2 min readJul 21, 2022

Now that we have looked at the outline of the system, it’s time to break down each section of gameplay into the new system.

In this example, the play can walk forward or backwards with “W” and “S” and rotate with “A” and “D”.

Basic movement

In the new input system, we create a new action map for the Player, then add a new action for walking. This control type is a Vector2, as we are only moving on a 2D plane with this character.

We are only interesting in the “Walk” function for now.

In the Player Manager Script, we initialize the action map and log the performs of the actions.

Next, we set local variables to take the Vector2 data from the Input system and then send it to the Player script (where the movement command is actually located).

Converting the Vector2 data into a new variable, move.

On the player script, we convert the “move” variable into a local variable “newmove”.

Finally, we convert the X and Y values into of the Vector2 into floats to serve as the axis’. We set the rotation, the speed of the movement, the animator, and finally we move the controller (thus moving the player).

And that’s simple movement in the new Input System!

--

--

Jack Leavey

I am a software engineer with years of experience branching into game development, specifically in Unity. Follow along for guides on creating game mechanics!