// Update is called once per frame void Update() { Collider[] hits = Physics.OverlapSphere(hitPoint.position, radius, enemyLayer); foreach (Collider c in hits) { if (c.isTrigger) { continue; } enemyHealth = c.gameObject.GetComponent <Enemy_Health>(); collided = true; if (collided) { Instantiate(attackEffect, hitPoint.position, hitPoint.rotation); enemyHealth.EnemyTakeDamage(damageCount); } } }
// Update is called once per frame void Update() { Collider[] hits = Physics.OverlapSphere(transform.position, radius, zombieLayer); foreach (Collider c in hits) { if (c.isTrigger) { continue; } attackTarget = c.gameObject.GetComponent <Enemy_Health>(); collided = true; if (collided) { Instantiate(damageEffect, transform.position, transform.rotation); attackTarget.EnemyTakeDamage(damageCount); } } }