This tutorial uses Unity (v2022.3.6f1) and the new input system (v1.6.3)
In this tutorial, I am going to show you the best way to use the new input system in your unity project. This is of course my opinion!
I loved the way the old input manager worked, but I also love the way the new input system. It allows for input changes during runtime, has great support for gamepads and is just more modern.
You can use the new input system in a couple of different ways, this way is pretty similar to the old input manager.
The first step is to create a Input Actions Asset with the correct bindings. Check out this link for a tutorial on how to do this.
Make sure you import UnityEngine.InputSystem
!
Create a public field for your Input Action and drag it in the inspector.
public InputActionReference movement;
Simply get the Vector2 from the InputActionReference.
Vector2 input = movement.action.ReadValue<Vector2>();
Create a public field for your Input Action and drag it in the inspector.
public InputActionReference jump;
Check if the action was triggered in Update()
if (jump.action.WasPressedThisFrame()) Jump();
Other types are the same as the Vector2 example, you just need to change the ReadValue<>()
type.