Hello! I am making a SHMUP game, and I want the player to lose a life if it collides with an asteroid object. Unfortunately, both the asteroid and the player are triggers (the player doesn’t have to be a trigger, but I can’t get it to collide when it isn’t either), so I can’t figure out how to get the 2 triggers to collide. I read that if they have rigidbodies 2 triggers can collide, so I added rigidbodies to both (with gravity disabled), but it’s still not working. Here is the code I have attached to my player’s body:
#pragma strict
var lives = 3;
function Update ()
{
if(lives < 1)
{
Application.LoadLevel ("GameOver");
}
}
function OnTriggerEnter(other: Collider)
{
if(other.gameObject.tag == 'Enemy')
{
lives -= 1;
}
Destroy(gameObject); //this is only here to test if the collision is working at all and it's not a problem with the above if statement, it's not going to be in the game. It still isn't working
}