- Home /
how do i count leftover enemies in screen?
hy guys, i'm confused how to count leftover enemies in screen (they are not destroy), let'me to show my code
public int ScoreValue; public int penalty;
// Increment score by ScoreValue if enemies destroy
if (health > 0) { health--; }
//Check the Health if less or equal 0
else if (health <= 0)
{
Instantiate(Explosion, transform.position, transform.rotation);
SharedValues_Script.score += ScoreValue;
Destroy(gameObject);
}
so, i want count leftover enemies are not destroy in screen.
if (health == 1) { SharedValues_Script.score -= penalty; }
but, i dont no, where i must put it. because i try put like this,
if (health == 1) { SharedValues_Script.score -= penalty; }
if (health > 0)
{
health--; //Decrement Health by 1
}
else if (health <= 0)
{
Instantiate(Explosion, transform.position, transform.rotation);
SharedValues_Script.score += ScoreValue;
Destroy(gameObject);
}
the output is: if player attack and enemy health is decrease, then penalty is increase 1(+=1), not leftover enemies counting..
Wish there That will help, thank you.. ^^
Comment