- Home /
 
               Question by 
               cacysunlee · Feb 05, 2011 at 11:10 PM · 
                destroygameobjects  
              
 
              destroy delete the component, not the game object
in my memory game i have in function Update () this script, but this delete only the script-component "RotateByClick" and not the GameObject as i wish
var twoCards = FindObjectsOfType(RotateByClick);
 for (var areCards : RotateByClick in twoCards) {
  if(areCards.isRotated == true){
  Destroy (areCards);  //delete here the two cards
  }
 }
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by tertle · Feb 05, 2011 at 11:22 PM
Try get a reference to the gameobject and delete that.
This might work, haven't tested.
var twoCards = FindObjectsOfType(RotateByClick);
 for (var areCards : RotateByClick in twoCards) {
  if(areCards.isRotated == true){
  Destroy (areCards.gameObject);
  }
 }
now i have the error : 'GameObject' is not a member of 'RotateByClick'.
fantastic! now it works, thank you very much tertle and $$anonymous$$olix ! :)
Your answer
 
 
             Follow this Question
Related Questions
Pooling everything...or not? 1 Answer
Destroy gameobject component that inherits from a certain class 3 Answers
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
Is it possible to destroy a gameobject from a child gameobject's script? 1 Answer
Help with Destroy Object 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                