Player Movement — Unity New Input System

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!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jack Leavey

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!