I’m trying to Destroy a terrain when an object flies into it.
The object is a cube, it’s set to ‘is trigger’, has a rigid body that listens to gravity, and has a script that looks like this:
function OnTriggerEnter ( other : Collider )
{
print ("YES1");
Destroy ( other );
if( other.gameObject.tag == "Terrain")
{
Destroy ( other );
Destroy ( this );
print ("YES2");
}
}
When I drop the Cube onto the Terrain piece, “YES1” is printed to the console, meaning that the collision IS detected. But at no point does the terrain piece disappear. Help!