Hello, I been looking for hours the next problems, let me explain. I’m following a tutorial from
Brackeys to create a Tower Defense game. The problem comes next, creating the area damage of the Misile Launcher, in the video shows correctly how to do it with Physics.OverlapSphere.
I have the same structure, everything the same but when I play the game the “Enemy” TAG doesn’t get destroyed, looks like the code never gets in to destroy target. Help please
void HitTarget() {
GameObject effectIns = (GameObject)Instantiate(impactEffect, transform.position, transform.rotation);
Destroy(effectIns, 2f);
if (explosionRadius > 0f)
{
Explode();
}
else
{
Damage(target);
}
Destroy(gameObject);
}
void Explode()
{
Collider[] colliders = Physics.OverlapSphere(transform.position, explosionRadius);
foreach (Collider collider in colliders)
{
if (collider.tag == "Enemy")
{
//Never gets in and due to this the target once gets hit, never dies, Turrets without area damage works perfectly well
Damage(collider.transform);
}
}
}
void Damage(Transform enemy)
{
//Area damage turret never joins here
Destroy(enemy.gameObject);
}
Minute 11:30
[
](http:// https://www.youtube.com/watch?v=LJLWNnqAjQ4)