Eu não sei o que está de errado, foi mudar para o GameManager que tudo começou a dar erro.
using UnityEngine;
public class PlayerBehavior : MonoBehaviour
{
[SerializeField] private float speed = 5;
private void Update()
{
float moveDirection = GameManager.Instance.InputManager.Movement;
transform.Translate(moveDirection * Time.deltaTime * speed, 0, 0);
}
}
using UnityEngine;
public class GameManager : MonoBehaviour
{
public static GameManager Instance;
public InputManager InputManager { get; private set; }
private void Awake()
{
if (Instance != null) Destroy(this.gameObject);
Instance = this;
InputManager = new InputManager();
}
}
public class InputManager
{
private PlayerControls playerControls;
public float Movement => playerControls.Gameplay.Movement.ReadValue<float>();
public InputManager()
{
playerControls = new PlayerControls();
playerControls.Gameplay.Enable();
}
}