Untitled
unknown
plain_text
a year ago
1.1 kB
7
Indexable
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; public class InputManager : MonoBehaviour { public PlayerInput playerInput; public PlayerInput.MovementActions movementAction; public PlayerMotor motor; public PlayerLook look; // Start is called before the first frame update void Awake() { playerInput = new PlayerInput(); movementAction = playerInput.Movement; motor = GetComponent<PlayerMotor>(); movementAction.Jump.performed += ctx => motor.Jump(); look = 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() { look.ProcessLook(movementAction.Look.ReadValue<Vector2>()); } private void OnEnable() { movementAction.Enable(); } private void OnDisable() { movementAction.Disable(); } }
Editor is loading...