// collision to get damage and die. void OnTriggerEnter2D(Collider2D col) { Shoot missile = col.GetComponent <Shoot>(); if (missile) { HP -= missile.GetDamage(); if (HP <= 0) { Score.points += point; Destroy(gameObject); } } }
// function to hit the player. void OnTriggerEnter2D(Collider2D col) { Shoot missile = col.GetComponent <Shoot>(); if (missile) { HP -= missile.GetDamage(); if (HP <= 0) { Destroy(gameObject); Die(); } missile.Hit(); } }
void OnTriggerEnter2D(Collider2D col) { Debug.Log(col); Shoot missile = col.gameObject.GetComponent <Shoot>(); if (missile) { //zadaje dmg health -= missile.GetDamage(); //niszczy rakiete przy trafieniu missile.Hit(); if (health <= 0) { Destroy(gameObject); scoreKeeper.Score(scoreValue); } } }
void OnTriggerEnter2D(Collider2D col) { Debug.Log(col); Shoot missile = col.gameObject.GetComponent <Shoot>(); if (missile) { //zadaje dmg health -= missile.GetDamage(); //niszczy rakiete przy trafieniu missile.Hit(); if (health <= 0) { AudioSource.PlayClipAtPoint(death, transform.position); Destroy(gameObject); GameObject smokePuff = Instantiate(smoke, transform.position, Quaternion.identity) as GameObject; scoreKeeper.Score(scoreValue); } } }
void OnTriggerEnter2D(Collider2D col) { Shoot missile = col.gameObject.GetComponent <Shoot>(); if (missile) { bool CoolingDown = true; //zadaje dmg health -= missile.GetDamage(); //niszczy rakiete przy trafieniu missile.Hit(); if (CoolingDown == true) { Health.fillAmount -= 0.25f; } if (health <= 0) { Destroy(gameObject); SceneManager.LoadScene("Start Menu"); } } }