#OverlapBoxAll returns just one collider

1 messages · Page 1 of 1 (latest)

vestal fulcrum
#

The blue highlighted gizmo area is clearly on two colliders and it should detect them and log "2", but I keep getting "1". Do you know what might be happening?

[SerializeField] private LayerMask _layerMask;
[SerializeField] private BoxCollider2D _box2D;

private void FixedUpdate()
{
    Vector2 origin = (Vector2)_box2D.transform.position + _box2D.offset;
    Vector2 size = _box2D.size;

    var boxCast = Physics2D.OverlapBoxAll(origin, size, angle: 0f, _layerMask);
    Debug.Log(boxCast.Count());
}

private void OnDrawGizmos()
{
    Vector2 origin = (Vector2)_box2D.transform.position + _box2D.offset;
    Vector2 size = _box2D.size;
    Gizmos.color = Color.blue;

    Gizmos.DrawCube(origin, size);
}
shy current
#

Also of the object this script is on

vestal fulcrum
#

Sure, gimme a sec

#

Looking at them I noticed I forgot to change the layer on one of the prefabs :)

#

the issue is solved, thanks