PlayerLocomotionInput

 avatar
unknown
plain_text
2 months ago
1.0 kB
1
Indexable
using Player.FinalCharacterController;
using UnityEngine;
using UnityEngine.InputSystem;


namespace Player.FinallCharacterController
{
    public class PlayerLocomotionInput : MonoBehaviour, PlayerControls.IPlayerLocomotionMapActions
    {
        public PlayerControls PlayerControls {  get; private set; }
        public Vector2 MovementInput { get; private set; }

        private void OnEnable()
        {
            PlayerControls = new PlayerControls();
            PlayerControls.Enable();

            PlayerControls.PlayerLocomotionMap.Enable();
            PlayerControls.PlayerLocomotionMap.SetCallbacks(this);
        }

        private void OnDisable()
        {
            PlayerControls.PlayerLocomotionMap.Disable();
            PlayerControls.PlayerLocomotionMap.RemoveCallbacks(this);
        }

        public void OnNewaction(InputAction.CallbackContext context)
        {
            MovementInput = context.ReadValue<Vector2>();
            print(MovementInput);
        }
    }
}

Leave a Comment