Rigidbody not destorying on collision with barrier
I have bought a demo version of a unity scene, it's the retro synthwave pack. I am trying to make the car in this pack destroy when it hits the side of the roads/palm trees. As you can see, I have added box colliders to the sides of the roads, these are called DestructBarrier.
My script is as follows to destroy the car:
public class DestroyCar : MonoBehaviour
{
void OnCollisionEnter(Collision col)
{
if (col.gameObject.CompareTag("Barrier"))
{
Destroy(gameObject); //Then destroy the player
Debug.Log("destroyed");
}
}
}
Nothing happens, the debug.log doesn't come up or anything. Just weird.
Now, the colliders aren't triggers, and everything has a rigidbody on it. Does anybody know whats going on here? I just wanna destroy the car when it hits those barriers. As I said, i bought this pack off the unity store. I also used this script from the unity forums, I can't figure out where I'm going wrong at all!