Untitled
unknown
plain_text
2 years ago
1.3 kB
10
Indexable
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; public class InputManager : MonoBehaviour { public PlayerInputs playerInputs; public PlayerInputs.MovementActions movementAction; public PlayerMotor motor; public PlayerLook lookcs; // Start is called before the first frame update void Awake() { movementAction.Crouch.performed += ctx => motor.Crouch(); movementAction.Sprint.performed += ctx => motor.Sprint(); movementAction.Jump.performed += ctx => motor.Jump(); playerInputs = new PlayerInputs(); movementAction = playerInputs.Movement; motor = GetComponent<PlayerMotor>(); lookcs = GetComponent<PlayerLook>(); } void FixedUpdate() { // tell the playermotor to move using the value from our movement input action motor.ProcessMove(movementAction.MovementInput.ReadValue<Vector2>()); } private void LateUpdate() { lookcs.ProcessLook(movementAction.Look.ReadValue<Vector2>()); } private void OnEnable() { movementAction.Enable(); } private void OnDisable() { movementAction.Disable(); } }
Editor is loading...