- Home /
 
               Question by 
               Doctor-Nitros · Dec 13, 2015 at 02:56 PM · 
                camerainstantiateprefabdestroy  
              
 
              how to destroy camera instatiated from prefab?
Hello!
I want to make a simple script for menu cameras. When I'm pressing Space I want to spawn mainmenucam and destroy introcam and it kinda works,but it does not destroys the introcam
Here's my code so far
 var introcam : GameObject;
 var mainmenucam : GameObject;
 
 function Start () {
      
      Instantiate(introcam); 
 }
 
 function Update () {
 
  if (Input.GetKeyDown ("space")) 
  {
  Destroy(GameObject.Find("introcam"));
  
      Instantiate(mainmenucam);
  }
 
  if (Input.GetKeyDown ("up")) 
  {
  Destroy(GameObject.Find("mainmenucam"));
 
      Instantiate(introcam);
  }
 
 }
 
 
How can I fix this?
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Destroying Objects. 1 Answer
Cannot destroy child object in prefab- Error 1 Answer
problem whit Instantiate Prefabs position. 0 Answers
Issues with destroying a game object 2 Answers
Spawning problems with cameras 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                