I am trying to get all objects within a distance of the current object. the maxShootDistance
is set to 3, and when an object that is part of the ShootAt
layer gets near/in the circle, it is never picked up, and my debug outputs 0
. Why isn't it picking up the other 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); // This is always returning zero
/*
* Snipped other bits of code
*/
yield return new WaitForSeconds(shootSpeed);
}
}
}
Here are the properties that are assigned to the object that should have been picked up:
Why isn't my code picking up the object?