UnityGameProjectsCode / InTheDarkGame / Level / Drone / Un-used / DetectPlayer.cs
DetectPlayer.cs
Raw
using UnityEngine;

public class DetectPlayer : MonoBehaviour
{
    private DroneAIMod parentDrone;


    private void Awake()
    {
        parentDrone = GetComponentInParent<DroneAIMod>();
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            parentDrone.SetCanSeePlayer(true);
        }
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            parentDrone.SetCanSeePlayer(false);
        }
    }
}