private void OnTriggerStay2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { vida.EatDamage(); } }
private void OnTriggerEnter2D(Collider2D collision) { //碰到玩家,玩家死亡 if (collision.gameObject.tag == "Player") { player.EatDamage(); GameObject.Destroy(gameObject); return; } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Player") { Vida vida = collision.gameObject.GetComponent <Vida>(); if (vida.invincivle || vida.inCharging) { //donothing } else if (vida.guardian) { vida.LoseGuard(); } else { vida.EatDamage(); } } GameObject.Destroy(gameObject); }
void OnCollisionEnter2D(Collision2D collision) { //如果还没击中,且碰到了玩家 if (collision.gameObject.tag == "Player") { Vida vida = collision.gameObject.GetComponent <Vida>(); if (vida.invincivle || vida.inCharging) { //donothing } else if (vida.guardian) { vida.LoseGuard(); } else { vida.EatDamage(); } } Die(); }