Answer the question
In order to leave comments, you need to log in
How to fix this error NullReferenceException: Object reference not set to an instance of an object Damage.OnTriggerEnter2D?
I made a collider for melee range. When another object enters this collider, Unity throws an error
Script:
void AttackPoint()
{
Collider2D[] hit = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, enemyLayers);
}
private void OnDrawGizmosSelected()
{
if (attackPoint == null)
return;
Gizmos.DrawWireSphere(attackPoint.position, attackRange);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question