using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerInteract : MonoBehaviour
{
private void Update()
{
if (Input.GetKeyDown(KeyCode.E))
{
Debug.Log("E was pressed");
float interactRange = 2f;
Collider[] colliderArray = Physics.OverlapSphere(transform.position, interactRange);
foreach (Collider collider in colliderArray)
{
Debug.Log($"Collider: {collider.name}", collider);
if (collider.TryGetComponent(out Interactable interactable))
{
Debug.Log("collider detected");
interactable.Interact();
}
else
{
Debug.Log("Collider was not detected");
}
}
}
}
}