Advertisement
Guest User

GridTrigger.cs

a guest
Nov 5th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class gridTrigger : MonoBehaviour {
  5.  
  6.     Collider collider;
  7.     bool isColliding = false;
  8.  
  9.     // Use this for initialization
  10.     void Start () {
  11.         collider = null;
  12.     }
  13.    
  14.     void OnTriggerEnter(Collider other) {
  15.         collider = other;
  16.         isColliding = true;
  17.     }
  18.    
  19.     void OnTriggerExit(Collider other) {
  20.         isColliding = false;
  21.     }
  22.     // Update is called once per frame
  23.     void Update () {
  24.    
  25.     }
  26.    
  27.     // Check is grid cube free to use / does it overlap with specific object
  28.     public bool isTriggered (GameObject isInTrigger){
  29.         bool localBool = false;
  30.         if(collider != null){
  31.             if(isInTrigger == null){
  32.                 localBool = true;
  33.             }
  34.             if(collider == isInTrigger.collider){
  35.                 localBool = true;
  36.             }  
  37.             if (collider == null){
  38.                 localBool = false;
  39.             }
  40.         }
  41.         return localBool;
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement