ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Linking Layer's Position with "Reflection Center" property of "Mirror" Effect

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mauro Achille
Linking Layer's Position with "Reflection Center" property of "Mirror" Effect
on Mar 29, 2018 at 4:09:49 am

Hi! In the "Mirror" Effect there's a property called "Reflection Center" based in "x,y" coordinates like the position property. I need to link just the x of "Reflection Center" to the x of the position of the layer, in a way that whenever I move the position away from or towards the composition's center, the same happens for the Reflection Center. I'm working in a 3840x2160 px resolution, so the center of the image is in x = 1920px.

In other words, if the x of the position increases untill it reaches 1920px, the x of the Reflection Center decreases proportionally untill it reaches 1920px aswell. and the same thing in the opposite direction of the x axes.

Manually modifying the position it automatically influences the Reflection Center. I hope it's not confusing!


Return to posts index

Steve Bentley
Re: Linking Layer's Position with "Reflection Center" property of "Mirror" Effect
on Mar 29, 2018 at 7:15:26 am

So as the x pos of the object increases you want the reflection center to decrease by the same amount but from the right hand side right?
The idea is that you take the value of the objects x position and subtract it from the right most pixel value of the frame (or any position you like really).

The code below assumes the layer you are moving is also the layer that has the mirror effect on it. If not you can change the second line to: MP=thisComp.layer("yourLayerNameHere").transform.position. or you can type MP= then pick whip the position value of the layer you want to choose as your object.

Position holds two values, x and y (or three, with a z, when it's 3D) and you access them with a [0] or [1] after the variable holding the position information (the first value, x is held in the zero position and NOT the 1 position, so if you had a third value for a 3D object it would be in the [2] slot.
When you want to access just one of the values of a multivalue attribute like Position or alter just one of them you put them between square brackets, and separate each one by commas: [xvalue, yvalue, zvalue]; the z value is only used for 3D. Or in your particular case [[MP[0], MP[1]]. We made MP = to the whole position value of your object in the second line.
You can also do a little math inside the square brackets too and that can save you a line of code, so inside the first value holder we're subtracting the xposition from the far right pixel value of the composition.

You can also do the whole thing in one line if you like too, getting the width of the comp to act as your far right position value.
[width-transform.position[0],transform.position[1]]

Doing it any of these ways also lets you go past the middle and the math will still work.

cmpSize=3840;
MP=transform.position;
[cmpSize-MP[0],MP[1]];




Return to posts index

Steve Bentley
Re: Linking Layer's Position with "Reflection Center" property of "Mirror" Effect
on Mar 29, 2018 at 7:16:45 am

I forgot to mention that the code goes on to the mirror reflection center attribute.



Return to posts index


Mauro Achille
Re: Linking Layer's Position with "Reflection Center" property of "Mirror" Effect
on Mar 29, 2018 at 3:03:05 pm

Thank you very mutch indeed!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]