Space Shooter Asteroid Not Destroying

I am trying to get the space shooter tutorial finished and I am using the done scripts, I am very new to writing code so I am using the done scripts. The bolts are colliding with the asteroids and giving an explosion, but neither are destroying. Same goes for the player. Explosion, neither destroy. I have tried copying the code from the web site and posting it into a new script and it does not work either. I am running OS 10.9.2. Please help, I am trying to teach this to some kids next week and I can not get this to work correctly.

using UnityEngine;
using System.Collections;

public class Done_DestroyByContact : MonoBehaviour
{
	public GameObject explosion;
	public GameObject playerExplosion;
	public int scoreValue;
	private Done_GameController gameController;

	void Start ()
	{
		GameObject gameControllerObject = GameObject.FindGameObjectWithTag ("GameController");
		if (gameControllerObject != null)
		{
			gameController = gameControllerObject.GetComponent <Done_GameController>();
		}
		if (gameController == null)
		{
			Debug.Log ("Cannot find 'GameController' script");
		}
	}

	void OnTriggerEnter (Collider other)
	{
		if (other.tag == "Boundary" || other.tag == "Enemy")
		{
			return;
		}

		if (explosion != null)
		{
			Instantiate(explosion, transform.position, transform.rotation);
		}

		if (other.tag == "Player")
		{
			Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
			gameController.GameOver();
		}
		
		gameController.AddScore(scoreValue);
		Destroy (other.gameObject);
		Destroy (gameObject);
	}
}

I had this same problem, then realized I didn’t check the “Is Trigger” box on the Capsule Collider for the asteroid.

This script should work… Brain dump of possible solutions follows

What’s happening inside your gameController.GameOver() ?

Any error messages?

Put a Debug.Log at the beginning of your OnTriggerEnter and immediately before the call to Destroy()

Are you using 3D physics or 2D physics?

if anyone comes looking, a problem that i had was that I had set the Spawn Values for the asteroid inside the GameController gameobject to be 1 on the Y-axis and this was causing the colliders to not intersect at all. I couldn’t tell that was the problem because of the top down view and because I was a moron. Spent some time on this one so thought I’d share.

I recommend you to do something like this maybe it will work.

var explosionPrefab : Transform;

var certainGameObjectName : String = "Bob";
 
function OnCollisionStart(collision : Collision)
{
if (collision.gameObject.name == certainGameObjectName)
{
Destroy(collision.gameObject); // destroys the thing this script bumped into
}

just use your spaceship to instanciate an object with this script it think.