FORUMS: list search recent posts

# Expression for moving towards another layers position, and keep going past it...?

FAQ   •   VIEW ALL
 Expression for moving towards another layers position, and keep going past it...? on Jun 29, 2013 at 7:54:28 pm

Hello,

here is my problem. I have a layer I am 'aiming' for ("target") and another that I want to move towards that layer ("mover"). However, instead of it just going to the target location and stopping (ie: the linear/easeIn/easeOut expression), I'd like the "mover" layer to keep going past the target position.

Ideally, I'd like to be able to simply duplicate the 'mover' layer and to multiple instances of it from different positions, yet they would all move towards (and past) the target.

Would anyone know how this could be done?

 Re: Expression for moving towards another layers position, and keep going past it...?on Jun 29, 2013 at 11:41:04 pm

This might work, depending on what you need:

moveDuration = 2;
moveStart = inPoint;
moveEnd = moveStart+moveDuration;
target = thisComp.layer("target").transform.position.valueAtTime(moveEnd);
if (time < moveEnd)
linear(time,moveStart,moveEnd,value,target)
else
target + (time-moveEnd)*(target-value)/moveDuration;

Dan

 Re: Expression for moving towards another layers position, and keep going past it...?on Jul 1, 2013 at 6:42:49 pm

Thanks Dan! Worked like a charm.

If you have the time, may I ask what is going on in the expression? I thought I would need to use a variety of math/trig functions to figure it out, but yours seems free of that. No worries if you do not have the time.

 Re: Expression for moving towards another layers position, and keep going past it...?on Jul 1, 2013 at 7:06:19 pm

After the layer reaches the target, the expression just calculates the velocity vector per unit of time and multiplies that by the time that has elapsed since the target was reached and adds that vector to the target's position. It only works because the move from the starting position to the target is linear.

Dan

 Re: Expression for moving towards another layers position, and keep going past it...?on Mar 13, 2014 at 12:17:04 am

in a similar vein:
I am looking for an expression which moves a layer to the position of the layer above it.
Thus if I have layer 2 key-framed at position A, B then it will move over time to the (target)layer 1 key-framed at position C, D

The idea is to apply this expression independently to individual layers to inherit a move towards the a layer above it.

possible?

So gravity would be a further advancement.

Pinewood Studios, UK