UnityGameProjectsCode / NightwatchGame / CarInfo.cs
CarInfo.cs
Raw
using UnityEngine;

public class CarInfo : MonoBehaviour
{
    public InteractionTextControl textControl;
    public GameObject interactionUI;
    private bool playerNearby;

    private void OnTriggerEnter(Collider other)
    {
        playerNearby = true;
        interactionUI.SetActive(true);
    }

    private void OnTriggerExit(Collider other)
    {
        playerNearby = false;
        interactionUI.SetActive(false);
    }

    private void Update()
    {
        if (playerNearby && Input.GetKeyDown(KeyCode.E))
        {
            textControl.DisplayText("Someone left their car running.");
        }
    }


}