Advertisement
Guest User

Sensor

a guest
Mar 28th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Sensor : MonoBehaviour {
  5.  
  6.     public static GameObject captureTarget;
  7.  
  8.     public static GameObject containTarget {
  9.         get {
  10.             return captureTarget;
  11.         }
  12.         set {
  13.             captureTarget = value;
  14.         }
  15.     }
  16.  
  17.     void OnTriggerEnter2D(Collider2D other) {
  18.         containTarget = other.gameObject;
  19.         //Debug.Log(containTarget.tag);
  20.     }
  21.  
  22.     void OnTriggerExit2D(Collider2D other) {
  23.         if(containTarget != null){
  24.             containTarget = null;
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement