Unity’s New Input System: Upgrading Player Movement
Hello all!
Today, I will be going over how to upgrade an old project with the old input system to the new one!
Adding the Input Action Map
Set up your action map with a Vector2 action, then assign the desired keys you want to add. I set mine to WASD and an XBOX controller for finer control.
- When you want the finer control from a joystick, set the mode to analog. If you keep it as digital, it will just move full speed as soon as you touch the joystick. Analog gives float and digital gives int values.
Changing up the Script
First, let’s look at the old code.
In the old input system, you can assign default keys in the Project Settings>Input Manager. When it says Input.GetAxisRaw(), it’s just pulling the default inputs, which is usually the arrow or WASD keys.
So, this is saying that you rotate when you hit keys from a horizontal input, then translate when you hit a vertical input.
Now the new:
It’s basically the same, but instead of using the Input.GetAxisRaw(), you only need to pull the Vector2 values and multiply them by their respected movement!
And that was how to upgrade your movement input!
Next up, I will change the interactable’s input.
See you then!