34 lines
778 B
C#
34 lines
778 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class GameInput : MonoBehaviour
|
|
{
|
|
|
|
public event EventHandler OnInteractAction;
|
|
|
|
|
|
private PlayerInputActions playerInputActions;
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
playerInputActions = new PlayerInputActions();
|
|
playerInputActions.Player.Enable();
|
|
|
|
playerInputActions.Player.Interact.performed += Interact_performed;
|
|
}
|
|
|
|
private void Interact_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
|
|
{
|
|
OnInteractAction?.Invoke(this, EventArgs.Empty);
|
|
}
|
|
|
|
public Vector2 GetMovementVectorNormalized()
|
|
{
|
|
Vector2 inputVector = playerInputActions.Player.Move.ReadValue<Vector2>();
|
|
|
|
inputVector = inputVector.normalized;
|
|
|
|
return inputVector;
|
|
}
|
|
}
|