How to make object dissapear using length() and opacity parameter
I have a certain structure:
With the Text layer, I display the distance between the two layers and, starting from the minimum number, I prescribe in my condition at what distance the opacity of my object will be 0 and he disappear
(Blue square is moving and bee need to dissapear when square come close to my bee)

But the problem is that the object does not disappear forever and after increasing the distance the object reappears, I tried to fix it using valueAtTime() but I dont understand rly how it works
I really need help, maybe I didn’t explain well, because I don’t speak English very well, if you have questions, ask
const halfASecond = 0.5;
const now = time;
const halfASecondAgo = now - halfASecond;
const prevValue = valueAtTime(halfASecondAgo);
Dist = length(thisComp.layer(1).transform.position, transform.position).toFixed(0);
if (prevValue === 0 || Dist <= 66) { // Number in my Dist var. is the closest distance i can see in my Source Text
0;
} else {
100;
}

