The problem with the following code is that if an enemy hits me invincible becomes true and after 2.5 seconds it becomes false again meaning I can once again get hit, however, if I am colliding with the trigger when invincible becomes false I dont get hit. In order for me to once again get hit I need to move out of the trigger first then re-enter it. Any solutions?
function OnTriggerEnter (other : Collider)
{
if (!invincible)
{
if(other.gameObject.tag == "Enemy")
{
hit = true;
invincible = true;
yield WaitForSeconds (2.5);
invincible = false;
}
}
}