So, I’m following the Space Shooter tutorial and in the explosion part there’s code that makes the player explode when it comes into contact with an Astroid. On the video both explode but with mine it the Player just pushes the astroid away.
Here’s the code that the video had me write, I’ve checked it a hundred times and it appears to be the same code.
using UnityEngine;
using System.Collections;
public class DestroyByContact : MonoBehaviour {
public GameObject explosion;
public GameObject playerExplosion;
void OnTriggerEnter(Collider other)
{
if (other.tag == "Boundary")
{
return;
}
Instantiate (explosion, transform.position, transform.rotation);
// this is the part that suppose to make the player explode when it touches the Astroid
if (other.tag == "Player")
{
Instantiate (playerExplosion, other.transform.position, other.transform.rotation);
}
Destroy (other.gameObject);
Destroy (gameObject);
}
}