I was just fooling around with the space tutorial, and while trying to figure out how to get a destroyed asteroid event to talk to the gamecontroller to alter the score (or kill the player) - the Destroy() that used to work now doesn’t.
Current code:
if (other.tag == "Player")
{
Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
gameController.GetComponent<GameController>().asteroidCollidedEvent();
Destroy(other.gameObject);
}
else
{
Instantiate(explosion, transform.position, transform.rotation);
gameController.GetComponent<GameController>().asteroidShotEvent();
Destroy(this.gameObject);
}
Old (working) code:
if (other.tag == "Player")
{
Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
Destroy(other.gameObject);
}
else
{
Instantiate(explosion, transform.position, transform.rotation);
Destroy(this.gameObject);
}
Any idea why this is happening and how to fix this? Thanks again!