I am trying to get all objects at a distance from the current object. the parameter is maxShootDistanceset to 3, and when the object, which is part of the layer ShootAt, approaches / in the circle, it is never matched, and my debugging outputs 0. Why doesn't he collect another object?
public class QuckShot : Gun {
void Start () {
StartCoroutine(shoot());
}
IEnumerator shoot(){
while(true){
Collider2D[] hitColliders = Physics2D.OverlapCircleAll(transform.position, maxShootDistance, LayerMask.NameToLayer("ShootAt"));
Debug.Log(hitColliders.Length);
yield return new WaitForSeconds(shootSpeed);
}
}
}
Here are the properties that are assigned to the object that should have been selected:

Why is my code not capturing an object?
source
share