Two objects BOTH with Destroy(other.gameObject) aren't destroying each other??

possibly a newby question here, but… i’ve got two bullet objects that, when they hit eachother, won’t destroy each other… both have rigidbodies and colliders, one with a tag check,one without any tag checking… (come at bottom) they both destroy everything else they are supposed to destroy, but when they hit eachother they just bounce and float off… at first i thought it was from detectcollision, but then they wouldn’t bounce, just pass through, so i don’t have a clue what’s up…

code 1, on “bullet” object tagged “Player”

function OnTriggerEnter (other : Collider) 
{
	Destroy(other.gameObject);
	Destroy(this.gameObject);

}

code 2, on “enemybullet” object tagged “Enemy” (yeah i know, real original huh?)

function update()
{
 rigidbody.detectCollisions = false;
 if (transform.position.z <= -13)
 {
 rigidbody.detectCollisions = true;
 }
if (transform.position.z <= -20)
{Destroy(this.gameObject);}
}


function OnTriggerEnter (other : Collider) 
{

  
   if(other.gameObject.tag=="Player")
   {
	Destroy(other.gameObject);
	Destroy(this.gameObject);
	 Debug.Log("EXTERMINATE!");
	 AddSingleCubeFab.prevFab =false;
	}

}

	i took classes in c++ but my scripting class is using javascript, so i'm learning as i go here, any help would be GREAT!

are your bullets collider two primitives collider or two meshes collider. because collision between two meshes collider which are no primitives (cube, etc...) are not doing well.

two primitives.. 1. sphere prefab and 2. cylinder prefab. I'm still taking an introductory course, so they didn't extensively cover using meshes in this course. the only objects i use (rigidbody objects) are always primitives.

asafsitner: thanks you! previous reply doesn't seem to have gone through, so i'm saying again, thank you! didn't think of OnCollisionEnter ... i think i read about it, but i don't remember it being covered in class, so i was unfamiliar with it. after looking it up in the reference pages, it looks like it should work perfectly! i'm too tired to mess with it tonight, but tomorrow i'll try it out and once i've confirmed it works i'll switch this thread to "answered"

1 Answer

1

Are they triggers at all? You say ‘bounce off’ which sounds to me like they have regular colliders, while you’re trying to destroy them with an OnTriggerEnter.

Try to change that into OnCollisionEnter

Just converted this to an answer to keep from showing under 'unanswered' category