Add interaction input handling

This commit is contained in:
BuyMyMojo 2023-02-28 03:19:49 +11:00
parent 72a0daf486
commit 5772da3965
5 changed files with 116 additions and 2 deletions

View file

@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@ -5,13 +6,25 @@ 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>();