I’m getting this error on my Player.cs script and my game input script that is accessing my Player script How can I fix it?
player.cs
public class Player : MonoBehaviour
{
[SerializeField] private float moveSpeed = 7f;
[SerializeField] private float rotateSpeed = 10f;
[SerializeField] private GameInput gameInput;
private bool isWalking;
private void Update(){
Vector2 inputVector = gameInput.GetMovementVectorNormalized();
Vector3 moveDir = new Vector3(inputVector.x, 0f, inputVector.y);
transform.position += moveDir * moveSpeed * Time.deltaTime;
isWalking = moveDir != Vector3.zero;
transform.forward = Vector3.Slerp(transform.forward, moveDir, Time.deltaTime * rotateSpeed);
}
public bool IsWalking(){
return isWalking;
}
}
GameInput.cs
public class GameInput : MonoBehaviour {
private PlayerInputActions playerInputActions;
private void Awake()
{
PlayerInputActions playerInputActions = new PlayerInputActions();
playerInputActions.Player.Enable();
}
public Vector2 GetMovementVectorNormalized()
{
Vector2 inputVector = playerInputActions.Player.Move.ReadValue<Vector2>();
inputVector = inputVector.normalized;
print("working");
return inputVector;
}
}