Question by
orangejsx6505 · Mar 27 at 02:38 AM ·
physics2dcollider2d
OverlapCircleAll returns null
Trying to detect an enemy collider using overlap circle all. The enemy type has only a kinematic rigid body and a 2d box collider.
attackPos = new Vector2(playerTransform.position.x + hitboxDistance, playerTransform.position.y);
Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(attackPos, hitboxRadius, enemyLayers);
Debug.Log("Hitbox Distance: " + hitboxDistance + " Hitbox Radius: " + hitboxRadius);
Debug.Log("Hitbox x: " + attackPos.x + " hitbox y: " + attackPos.y + " enemies hit: " + hitEnemies.Length);
The circle should definitely be over the enemy according to the debug messages, but the array is still empty. Currently, enemyLayers is set to everything. Any ideas?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613054651im_/https://answers.unity.com/themes/thub/images/avi.jpg)