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”.
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.
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).
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!