- Home /
              This question was 
             closed Jan 16, 2012 at 07:10 AM by 
             syclamoth for the following reason: 
             
 
            Duplicate Question
 
               Question by 
               noobakashi · Jan 16, 2012 at 07:10 AM · 
                collisiondestroyprefabs  
              
 
              Collision between 2 prefabs.
I'm trying to detect collision between a bullet and a target both of them are prefabs that are moving objects. This is the code i've attached to the bullet for detecting collision using UnityEngine; using System.Collections;
public class collision : MonoBehaviour {
 void OnCollisionEnter(Collision collide){
     
     if(collide.gameObject.name == "target"){
         
         print("hit");
         Destroy(collide.gameObject);
         Destroy(this.gameObject);
     }
              
 }
}
Both the target and bullet are rigidbodies and collide and everything but the code within if statement is not getting executed..
               Comment
              
 
               
              Follow this Question
Related Questions
Collision between 2 prefabs. 1 Answer
How to only delete one of two collided objects? 1 Answer
Destroying all objects with a certain tag that ray cast if colliding with 0 Answers
How to destroy bullet on collision! 2 Answers
The object of type 'Rigidbody' has been destroyed but you are still trying to access it. 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                