unity input system controller code example

Example 1: unity controller input

float moveSpeed = 10;
//Define the speed at which the object moves.

float horizontalInput = Input.GetAxis("Horizontal");
//Get the value of the Horizontal input axis.

float verticalInput = Input.GetAxis("Vertical");
//Get the value of the Vertical input axis.

transform.Translate(new Vector3(horizontalInput, 0, verticalInput) * moveSpeed * Time.deltaTime);
//Move the object to XYZ coordinates defined as horizontalInput, 0, and verticalInput respectively.

Example 2: how to stop clear input new input system unity

_controls.Player.Move.started += ctx => movementInput = ctx.ReadValue<Vector2>()
_controls.Player.Move.performed += ctx => movementInput = ctx.ReadValue<Vector2>()
_controls.Player.Move.canceled += ctx => movementInput = ctx.ReadValue<Vector2>()