Disabling Children

I’m trying to disabling a Sphere at the start of the scene. The Sphere has a child object that I also want disabled, but for some its not doing it.

var bouncie : GameObject;
var seconds = 0.0;
var running = false;

function Start () {

bouncie.active = false;
}


function Update () {
	
if (running) {
  
   timeLeft = seconds - Time.time;
   timeLeft = Mathf.Max (0, timeLeft);
   seconds -= Time.deltaTime;
  
   }
   
if (seconds <= 0.0)
  
  {
   
   bouncie.active = true;
   
    }
  
  var hit : RaycastHit;

   for (var evt : iPhoneTouch in iPhoneInput.touches)   
     {
     	 if (evt.phase == iPhoneTouchPhase.Began)
     	  { 
      var ray = camera.main.ScreenPointToRay(evt.position);
      
          if(Physics.Raycast(ray, hit, 50)  hit.collider.tag == ("Blue")) {
          
       		if (iPhoneInput.touchCount == 1) { 
      			if (iPhoneInput.GetTouch(0).tapCount == 1) { 
     				
     		
      		bouncie.renderer.enabled = false;
      		Debug.Log("Hit");
          	}
          }
		}
	  }
     }


if (bouncie.renderer.enabled == false) {
bouncie.active = false;
	}

}

use SetActiveRecursively (false) that should do the trick :slight_smile:

hope it helps!

Thanks that did the trick! If I could sneak another question in here, I’m have a huge problem disabling the clones of the Sphere. I’m using Instantiate to clone the Sphere every few seconds. I want to Tap on the Spheres and have them disable one at a time, but right now it only works on the original sphere, not the copies.
“Instantiate”

var player : GameObject;
private var Timer : float; 

function Update () {
	
      
    if ( Timer + 5 < Time.time ) { 
    	Instantiate(player, transform.position,transform.rotation); 
    	//Instantiate(player, Vector2(-25, 9.5), Quaternion.identity); 
    	Timer = Time.time; 
    }
    
   }

Tap

var character : GameObject;


function Update () {
	
var hit : RaycastHit;

   for (var evt : iPhoneTouch in iPhoneInput.touches)   
     {
     	 if (evt.phase == iPhoneTouchPhase.Began)
     	  { 
      var ray = camera.main.ScreenPointToRay(evt.position);
      
          if(Physics.Raycast(ray, hit, 50)  hit.collider.tag == ("Blue")) {
          
       		if (iPhoneInput.touchCount == 1) { 
      			if (iPhoneInput.GetTouch(0).tapCount == 1) { 
          
    
        character.active = false;
        character.SetActiveRecursively(false);

          
          	  }
          
          }
       }   

     	  }
     }
}

store the instantiated game objects somewhere (an array could do this) and just simply access the array where you stored them and deactivate/destroy/do whatever you want with them