Physics2D checking if object goes out of OverlapArea

I’m trying to do ladder in my2Dplatformer and i wanna check if playeris in range of ladder. And it works when he gets in but it doesn’t detect when player goes out of range of ladder and causing enemy to fly.

So here’s part of my code; this LayerMask is set to good layer.

   [SerializeField] LayerMask playerLayer;
    void Update() {
    Collider2D coll = Physics2D.OverlapArea(pointA.transform.position, pointB.transform.position, playerLayer);
        if (coll.gameObject != null)
            // switch on climbing
        if (coll.gameObject == null)
             // switch off climbing, this if doesnt work dont matter what i put in

OverlapArea only returns colliders that are inside the area. Once the collider is outside of the overlap area, OverlapArea no longer returns any collider. coll will be null, so coll.gameobject can’t be accessed. Similarly, any collider that gets returned will always have a gameobject assigned to it.


if(coll == null)