I have a composition in After Effects (CS6) that contains 2 objects that are usually a set distance apart. I am looking for an expression or other method to automatically move one layer by the same amount as its parent, but in the opposite direction (as in if the parent goes up 5 px the child should go down 5 px). So far I haven't been able to figure this out, but I am very new to expressions.


2 Answers 2


By having the layer parented you make it a bit harder. If you want the second layer to follow the x coord of the first layer, but mirror the y coord this will do it (without the second layer being parented)

var centerY = thisComp.height/2;
var p = thisComp.layer("the name of the controlling layer").transform.position;
[p[0], centerY - p[1]]

If do you need the second layer to be parented the following should work. Because the distance from the parent to the centre point is the same as the distance from the center point to the child, we can just multiply it by two to get the y distance in the layer space of the parent:

var centreY = thisComp.height/2;
[value[0], 2*(centreY - parent.position[1])];

Both of these expressions will mirror around the centre of the comp vertically. You could mirror around an arbitrary y point by specifying it on the first line instead of thisComp.height/2, e.g.: var centerY = 1234.

You could also use another layer as the control of the mirror point by using this instead of that expression: var centerY = thisComp.layer("name of center control layer").transform.position[1]


Maybe try the Kaleidoscope or mirror effect instead? Might achieve the same thing much more quickly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.