I have a piece of script that detects if it is hit by an object with a tag, like this:
void OnTriggerEnter(Collider other)
{
if (GameScript.iFrames <= 0f )
{
if (other.tag == "Asteroid")
{
Instantiate(explosion, transform.position, transform.rotation);
GameScript.Damage();
GameScript.playerActive = false;
Destroy(other.gameObject);
Ship.SetActive(false);
}
}
}
However, if I try to add to that check with another if statement, say:
if(other.tag == "Enemy")
It will often ignore it
Why is that, and how can I set up a single game object to detect different kinds of collisions? I looked into using a switch statement, but failed.(Thats not to say it could not work, I just failed at making it work). Any help would be really appreciated.