Hi all,
I’ve written the following script for a game I’m developing but currently having issues destroying all the objects with the tag name “block.” Below I’m including the script for the OnCollisionEnter script. I want the user to destroy everything with block when the collide/hit a purple material cube on screen.
void OnCollisionEnter (Collision col)
{
//Debug.Log (col.gameObject.name);
Score.score += (int)blockType;
if (lives == 0) {
Destroy (gameObject);
}
// If its blue do this otherwise continue!
if (mr.material.name == ("blockBlue mat")) {
//Debug.Log ("Blue block has been hit");
Lives.Instance.decrementLives ();
Destroy (gameObject);
} else if (mr.material.name == ("blockOrange mat")) {
Lives.Instance.incrementLives ();
Destroy (gameObject);
}
else if (mr.material.name == ("blockPurple mat")) {
Destroy (GameObject.FindGameObjectsWithTag("block"));
}
else {
lives = lives - 1;
}