Hello everyone.
my problem is that it does not affect the damage.
I use boxcollider to apply it.
and I would also like to find a way to activate a boxcollider using the left button, and another to keep the right button of the mouse, doing damage to all enemies within the collider.
I hope you can help me.
AudioSource audioSource;
public int damage = 10;
private Collider[] enemys;
void Start ()
{
audioSource = GetComponent();
}
void OnCollisionEnter(Collider collision)
{
foreach (Collider enemy in enemys)
{
if (enemy.tag == "Enemy")
{
audioSource.Play();
HealthBar health = collision.gameObject.GetComponent();
health.TakeDamage(damage);
}
}
}
}
↧









