Newer
Older
using System;
using Interactable;
using UnityEngine;
using UnityEngine.InputSystem;
public class InteractCursor : MonoBehaviour
{
private IInteractable m_currentInteractable;
private InputAction m_Interact;
private void Start()
{
m_Interact = InputSystem.actions.FindAction("Interact");
}
private void Update()
{
if (m_Interact.WasPressedThisFrame())
private void OnTriggerEnter2D(Collider2D other)
{
Debug.Log("Enter");
if (other.TryGetComponent(out SpriteRenderer sprite))
{
sprite.color = Color.blue;
}
if (other.TryGetComponent(out IInteractable interactable))
{
m_currentInteractable = interactable;
Debug.Log(m_currentInteractable);
private void OnTriggerExit2D(Collider2D other)
{
if (other.TryGetComponent(out SpriteRenderer sprite))
{
sprite.color = Color.white;
}
}
}