[ad_1]
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Anybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
Asked
Viewed
4 times
I have a object with box collider that spins 360 degree before destroying itself. I have a lot of enemies spawning around the player. The object spawns, spins and destroys itself. Imagine it like scythe. But only some enemies are getting damaged and some are not. The code is given below
private void OnTriggerEnter2D(Collider2D collision)
{
damage(collision.gameObject);
}
void damage(GameObject other)
{
if (other.gameObject.CompareTag("Enemies"))
{
//Damaging the enemy
other.gameObject.GetComponent<Health_Enemy>().health -= Damage;
other.gameObject.GetComponent<Health_Enemy>().check();
}
}
```
\$\endgroup\$
You must log in to answer this question.
default
[ad_2]