Detecting a collision with expressions
I have a layer moving along the X-axis. I have a shape layer with a simple stroke and trim paths that has the starting point of the stroke on the same X-axis. When the moving layer (m) reaches the same X value, I want the stroke to move up. This simple expression pops the line up to 100%
m = thisComp.layer("Mover").position;
r = position;
if (m[0] < r[0] || m[0] > r[0] + 60)
y = 0;
else
y = 100;
There are no keyframes at the time of the collision, so using time in an ease method is not working for me.
Is there some way to come up with an interpolation method that says
when m = r increase the value of y so that when m = r + 30, y == 100;
then as m moves from r+30 to r + 60, y changes from 100 to 0
If I had a keyframe where the collision occurs, it would be easy to use valueAtTime for the keyframe to create the growing and falling stroke. I can't figure out how to make it happen without a keyframe.
Any suggestions would be appreciated.
This could also be helpful in animating a countdown so as the numbers go from 10 to zero a line would grow and shrink instead of just blinking when each number is reached.

