-
Unlink two layers after a certain time in After Effects
I want to have a layer (let’s call it Leader) that moves and another one (let’s say Follower) whose position is linked to the first one’s, so it will have the same movement, but at a specific time t it should “unlink” from the first layer and stay in that position.
But for some reason I don’t understand, at time t, the Follower goes back to its original position instead of staying in the place in which it was “unlinked” from the Leader. What am I missing?
My idea is that, when trying to get the Follower‘s position, I am getting the original position, not the values that are changed according to the Leader‘s position, even though I tried to get the value from the previous frame, but I don’t know how to get the modified values of the position.
Here’s the closest I’ve come to getting it right:
var pos = value;
var p = thisComp.layer("Leader").transform.position;
t = 1; // Unlink after 1 second
if (time <= t) {
value + (p.value - p.valueAtTime(0));
}
else {
thisLayer.position.valueAtTime(t - thisComp.frameDuration);
}