🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Latest Null Activity
![NullReferenceException](https://uploads.gamedev.net/forums/monthly_2020_12/78d3bf70da084ecba4a11a4e2ac0aa46.image.png)
This is a place to leverage your debugger.
foreach (Collider2D enemy in hitEnemies)
{
enemy.GetComponent<EnemyHealth>().TakeDamage(attackDamage);
}
Most likely the collider being processed doesn't have an EnemyHealth component attached.
There are only a few other ways you could get the erro…
Advertisement
Advertisement