- Home /
 
               Question by 
               jb777 · Aug 05, 2011 at 03:30 AM · 
                gameobjectobjectdestroy  
              
 
              Destroy object when transform.position.x > 10.
I have a bullet prefab with a script.
void Update () {
     transform.Translate(5 * Time.deltaTime, 0, 0);//move bullet
     
     //check bounds
     if(transform.position.x > 10)
     {
         Destroy(this);    
     }
 }
The bullet moves on the x-axis but stops moving once it hits 10. The object is still alive and the mesh is still rendered. How do I destroy the entire object?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Ziad · Aug 05, 2011 at 03:32 AM
because Destroy(this); is used to destroy the script component not the game object u should use Destroy(gameobject); and this will fix it
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                