private void OnTriggerEnter2D(Collider2D collision) { rb = collision.GetComponent <Rigidbody2D>(); switch (collision.tag) { case "Player": player = collision.GetComponent <PlayerBase>(); invincibility = player.GetInvincibilityState(); Debug.Log(invincibility); if (player != null && !invincibility) { player.DamageFlash(); HeartsHealthVisual.heartsHealthSystemStatic.Damage(damageAmount); bounceVelocity = player.GetBounceVelocity(rb, 9f, 1.8f); rb.AddForce(new Vector2(0f, bounceVelocity), ForceMode2D.Impulse); player.SetInvincibilityState(true); } break; case "Enemy": enemy = collision.GetComponent <EnemyBase>(); invincibility = enemy.GetInvincibilityState(); if (!invincibility) { enemy.DamageFlash(); bounceVelocity = enemy.GetBounceVelocity(rb, 9f, 1.8f); rb.AddForce(new Vector2(0f, bounceVelocity), ForceMode2D.Impulse); enemy.SetInvincibilityState(true); } break; } }