Advertisement
Guest User

Detector

a guest
Aug 19th, 2019
143
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. using System;
  5.  
  6. public class Detector : MonoBehaviour
  7. {
  8.     private bool detectado;
  9.     public Action<bool> onReady;
  10.     private void OnTriggerEnter2D(Collider2D other)
  11.     {
  12.         if(other.CompareTag("Floor"))
  13.         {
  14.             detectado = true;
  15.             IsReady();
  16.         }        
  17.     }
  18.     private void OnTriggerExit2D(Collider2D other)
  19.     {
  20.         if (other.CompareTag("Floor"))
  21.         {
  22.             detectado = false;
  23.             IsReady();
  24.         }
  25.     }
  26.  
  27.     public void IsReady()
  28.     {
  29.         onReady(detectado);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement