private void OnTriggerEnter2D(Collider2D other) { //sound.Play(); tile = other.gameObject.GetComponent <projectile>(); if (tile) { Health -= tile.GetDamage(); if (Health <= 0) { Died(); } } }
private void OnTriggerEnter2D(Collider2D other) { //sound.Play(); projectile tile = other.gameObject.GetComponent <projectile>(); if (tile) { Health -= tile.GetDamage(); if (Health <= 0) { Destroy(gameObject); level.LoadLevel("Lose Screen"); } } }
void OnTriggerEnter(Collider collider) { projectile projectile = collider.gameObject.GetComponent <projectile>(); if (collider.tag == "cannonBall") { if (projectile) { // Debug.Log("Projectile"); health -= projectile.GetDamage(); projectile.Hit(); AudioSource.PlayClipAtPoint(hitSound1, transform.position); if (health <= 0) { Die(); } } } }