Guest User

Untitled

a guest
Jan 6th, 2016
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SetActiveOnTriggerEnter : MonoBehaviour {
  5.  
  6.     //public string FindGameOBJ; <-To be implemented for future re-usability. Ignore it for now.
  7.    // public string ComponentToActivate; <-To be implemented for future re-usability. Ignore it for now.
  8.  
  9.     void OnTriggerEnter (Collider coll) // Collision detection.
  10.     {
  11.         if (coll.tag == "Ball") //Checks the tag to see if it is the PARENT OBJECT.
  12.         {
  13.                 if (GameObject.Find("BallHealZone") == null) //Looks for the CHILD OBJECT, and if it is null than move forward.
  14.                 {
  15.                     Debug.Log("Activating BallHealZone! :)"); //Tells me if it found said object, and confirms it is indeed null (yes it works).
  16.                     gameObject.SetActive(true); //Activates the CHILD OF PARENT OBJECT.
  17.                 }
  18.         }
  19.     }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment