Destroy triggering Destroy

In a nutshell, I have two prefabs that are instantiated. They are two separate meshes that appear to be one. Long story short they need to remain separate. Object 1, has a collider on it, and is destroyed when it hits it’s target. Because of there proximity, Object 2 cannot have a collider on it. This simple script below, destroys Object 1 on impact.

What kind of code can I add to it so it can trigger object 2 getting destroyed?

#pragma strict

function  OnCollisionEnter (col : Collision) 
{
	
	Destroy(gameObject);
	
}
#pragma strict
     var otherObject : GameObject;


function  OnCollisionEnter (col : Collision) 
{
	Destroy(otherObject);
	Destroy(gameObject);
	
}

Hey buddy, your full of advice more me! Its much appreaited :slight_smile: I put in the code but it didn’t work :frowning:

What happens? Make sure you have a rigid body on one of the colliders and that you have dragged the second game object to the variable in the inspector.

Cant you just offset the 2 colliders, so they dont collide with each other? Or you just use a script like

function OnTriggerEnter(collider:Collision)
{
/// Only destroy game object if for example player hits the collider ///
if ( collider.tag == “Player” )
{
Destroy(gameObject);
}
}

here you have to set both rigidbodies to “Is Trigger” in the Inspector.

Thinks for the tips guys. What ended up work was I was able to parent object 2 under object one for the prefab. I should of thought of that a while ago :confused: