Guest User

gridTrigger.cs

a guest
Nov 8th, 2014
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.             Debug.Log ("toimii");
  32.             if(isInTrigger != null){
  33.                 if(collider == isInTrigger.collider){
  34.                     localBool = true;
  35.                 }  
  36.             }
  37.             if(isInTrigger == null){
  38.                 localBool = true;
  39.             }
  40.  
  41.             if (collider == null){
  42.                 localBool = false;
  43.             }
  44.         }
  45.         return localBool;
  46.     }
  47. }
RAW Paste Data