void OnTriggerEnter2D(Collider2D col) { projectile missile = col.gameObject.GetComponent <projectile>(); if (missile) { health -= missile.getDamage(); missile.Hit(); if (health <= 0) { Die(); } } }
void OnTriggerEnter2D(Collider2D col) { Debug.Log("Player has been hit"); projectile missile = col.gameObject.GetComponent <projectile>(); if (missile) { health -= missile.getDamage(); missile.Hit(); if (health <= 0) { Die(); } } }
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); } } }
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(); } } } }