Unity 4.6.1f1 Freeze after Physics2D.OverlapCircleAll()

Hi. When I use Physics2D.OverlapCircleAll() script in my game, when it has to be done all program get freeze and i must restart it. I found that hitColliders*.gameObject.GetComponent() is freezing program but i dont know why. It`s works few time and after this I always get freeze. Box Collider is in the same object where is HealthScript script. I shoud write this in another way?*
```csharp

  • void ExplodingSpearSkill() {
    if(gameObject.transform.position.y < Screen.height*0.1f) {
    ExplosionDamage(gameObject.transform.position, PlayerActiveSkills.explodingSpearStats[0]);
    Destroy(gameObject);
    }
    }
void ExplosionDamage(Vector3 center, float radius) {
    Collider2D[] hitColliders = Physics2D.OverlapCircleAll(center, radius);
    //Collider2D[] hitColliders = Physics2D.OverlapCircleNonAlloc(center, radius, hitColliders);
    int i = 0;

    Debug.Log("BUM : " + radius + " " + hitColliders.Length);
    while (i < hitColliders.Length) {
        if(hitColliders[i].gameObject.GetComponent<HealthScript>() != null) {
            Debug.Log("BUUUUUUM");
            hitColliders[i].GetComponent<HealthScript>().HP -= 100;//gameObject.GetComponent<ShotScript>().damage*PlayerActiveSkills.explodingSpearStats[1];
            i++;
        }
    }
}*

```
SOLUTION.
Sorry for this. I forget i have in scene unit which attack monsters by explosion and it collider was in array to. But my attacking unit dosent have healthScript :slight_smile: so thats all problem.

Not the problem - you should move i++ from inside the if, otherwise it will just keep retrying forever, and unity will crash.

Another solution would be to use
while(i++ < hitColliders.Length) {