Advertisement
kasru

Hide Object

Jan 30th, 2013
2,648
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //****** Donations are greatly appreciated.  ******
  2. //****** You can donate directly to Jesse through paypal at  https://www.paypal.me/JEtzler   ******
  3.  
  4. function Update() {
  5.  
  6.     var hit: RaycastHit;
  7.     var forward = transform.TransformDirection (Vector3.forward);
  8.  
  9.     if (Physics.Raycast (transform.position, forward, hit)) {
  10.  
  11.         if(hit.collider.CompareTag("hideObject")){
  12.  
  13.             Debug.Log("hit");
  14.             o = hit.collider.gameObject;
  15.             o.renderer.material.color.a = 0.2;
  16.     }
  17.     else {
  18.         var hides : GameObject[];
  19.         hides = GameObject.FindGameObjectsWithTag("hideObject");
  20.  
  21.     // Iterate through them and turn each one off
  22.     for (var hide : GameObject in hides) {
  23.         hide.renderer.material.color.a = 1.0;;
  24.     }
  25. }
  26.        
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement