void OnTriggerEnter2D(Collider2D collider) { projectile bullet = collider.gameObject.GetComponent <projectile> (); if (bullet) { hp -= bullet.GetDmg(); bullet.Hit(); if (hp <= 0) { Destroy(gameObject); keeper.Score(score); AudioSource.PlayClipAtPoint(deathSound, transform.position); } } }
void OnTriggerEnter2D(Collider2D collider) { projectile bullet = collider.gameObject.GetComponent <projectile> (); if (bullet) { hp -= bullet.GetDmg(); bullet.Hit(); if (hp <= 0) { AudioSource.PlayClipAtPoint(deathSound, transform.position); sr = GetComponent <SpriteRenderer> (); sr.sprite = destroyedPlayer; dead = true; //Destroy (gameObject); } } }