我正在尝试获取当前对象附近距离内的所有对象。 maxShootDistance
设置为 3,但是当属于 ShootAt
层的对象接近或进入圆形区域时,它们从未被捕获,我的调试输出显示为 0
。为什么其他对象没有被捕获?
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);
}
}
}
以下是应该被拾取对象所分配的属性:
![女性属性](https://istack.dev59.com/Zzcz0.webp)