private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "bullet") { Destroy(other.gameObject); Debug.Log("Hit2"); damage -= 50; if (damage <= 0) { Die(); ScoringSystem.EnemyKilled(); } } if (other.tag == "PLayer") { GameControlScript.health -= 1; Debug.Log("Hit1"); Destroy(this.gameObject); Player_sprite player = other.transform.GetComponent <Player_sprite>(); if (player != null) { player.Damage(); } } }
public void TakeDamage(int damage) { health -= damage; if (health <= 0) { Die(); ScoringSystem.EnemyKilled(); } }