Advertisement
Placido_GDD

StationDroneAggro

Dec 13th, 2021
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class StationDroneAggro : MonoBehaviour
  6. {
  7.     public GameObject droneTrgt;
  8.     public string droneTarget;
  9.     void OnTriggerEnter2D(Collider2D col)
  10.     {
  11.             if (droneTrgt == null && col.CompareTag(droneTarget))
  12.             {
  13.                 droneTrgt = col.gameObject;
  14.             }
  15.  
  16.     }
  17.  
  18.     void OnTriggerStay2D(Collider2D col)
  19.     {
  20.         if (droneTrgt == null && col.CompareTag(droneTarget))
  21.         {
  22.                 droneTrgt = col.gameObject;
  23.         }      
  24.     }
  25.     void OnTriggerExit2D(Collider2D col)
  26.     {
  27.             if (droneTrgt != null)
  28.             {
  29.                 Debug.Log("target is null");
  30.                 droneTrgt = null;
  31.             }
  32.     }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement