When I hit the play button, and no matter if I hit the left、right、up、down, or AWSD buttons, I just can’t get the input value, it always prints 0 to the console…
Below is my player movement script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
[SerializeField] float movementSpeed = 10;
[SerializeField] float xAxisRange = 5; //玩家可以移動的X軸範圍
[SerializeField] float yAxisRange = 5; //玩家可以移動的Y軸範圍
// Update is called once per frame
void Update()
{
float horizontalThrow = Input.GetAxis("Horizontal");
Debug.Log(horizontalThrow);
float verticalThrow = Input.GetAxis("Vertical");
Debug.Log(verticalThrow);
}
}
I’m sure I have implemented the script into the Player object
Could anyone help me figure out what I doing wrong?
My Unity version: 2022.3.7f1