I'm a Unity newbie. This time, I'm trying to make the Player operable with an Xbox controller using PlayerInput. However, when I control the player, I get these errors:
Errors that occurred:
[20:35:08] InvalidOperationException: Cannot read value of type 'Vector3' from control '/XinputControllerWindows/leftStick' bound to action 'Player/Move[/XInputControllerWindows/leftStick]'
[20:35:08] InvalidOperationException while execuring 'started' callbacks of 'Player/Move[/XInputControllerWindows/leftStick]'
The version is 2021.3.37f1. The work is made with something called 3D Sample Scene (URP).
PlayerInput
PlayerContoroller
using UnityEngine;
using UnityEngine.InputSystem;
using Vector2 = UnityEngine.Vector2;
using Vector3 = UnityEngine.Vector3;
public class PlayerController_PC : MonoBehaviour
{
private Rigidbody rb;
private Vector3 move;
private Vector3 moveForward;
[SerializeField]
private float moveSpeed;
[SerializeField]
private float turnTimeRate = 0.5f;
// Start is called before the first frame update
void Start()
{
rb = this.gameObject.GetComponent<Rigidbody>();
rb.constraints = RigidbodyConstraints.FreezeRotation;
}
// Update is called once per frame
void Update()
{
Move();
}
void FixedUpdate()
{
Rotation();
}
private void Move()
{
Vector3 cameraForward = Vector3.Scale(Camera.main.transform.forward, new Vector3(1, 0, 1)).normalized;
moveForward = cameraForward * move.z + Camera.main.transform.right * move.x;
moveForward = moveForward.normalized;
if (move.magnitude > 0)
{
rb.velocity = moveForward * moveSpeed * move.magnitude + new Vector3(0, rb.velocity.y, 0);
}
else
{
rb.velocity = new Vector3(0, rb.velocity.y, 0);
}
}
private void Rotation()
{
Vector3 cameraForward = Vector3.Scale(Camera.main.transform.forward, new Vector3(1, 0, 1)).normalized;
moveForward = cameraForward * move.z + Camera.main.transform.right * move.x;
moveForward = moveForward.normalized;
if (move.magnitude > 0)
{
Quaternion targetRotation = Quaternion.LookRotation(moveForward);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * turnTimeRate);
}
else
{
Quaternion targetRotation = transform.rotation;
transform.rotation = targetRotation;
}
}
public void OnMove(InputAction.CallbackContext context)
{
move = new Vector3(context.ReadValue<Vector3>().x, 0f, context.ReadValue<Vector2>().y);
}
}

