PlayerScript
unknown
csharp
a year ago
745 B
1
Indexable
Never
public class playerScrpt : MonoBehaviour { private CharacterController controller; public PlayerControls playerInput; [SerializeField] private float moveSpeed; private InputAction move; Vector3 moveDirection = Vector3.zero; private void Awake() { playerInput = new PlayerControls(); move = playerInput.Player.Move; } private void Start() { controller = GetComponent<CharacterController>(); } private void OnEnable() { move = playerInput.Player.Move; move.Enable(); } private void OnDisable() { move.Disable(); } // Update is called once per frame void Update() { moveDirection = move.ReadValue<Vector3>(); } private void FixedUpdate() { controller.Move(moveDirection * Time.deltaTime * moveSpeed); } }