FORUMS: list search recent posts

Problem with linking correct layer.pos to pos/scale of above layer

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jeremiah Batholomis
Problem with linking correct layer.pos to pos/scale of above layer
on Aug 19, 2016 at 4:23:52 pm

Hi,

i wrote an expression to link the (center)position of layer 2 to the center of layer 1. Depending on position and scale of layer 1. That works pretty good as long as the anchorpoint of layer 1 is a negative value – f.e. on the top/left corner.

What do i have to write to get this script working, independently from the position of the anchor point of layer 1?

Thx!!

Btw. Take a look at the AE-File attached!!
10440_automaticposmask.aep.zip

// --- Maskenebene

a = thisComp.layer(index-1);

//--- Y ----

h = a.height;
sh = a.transform.scale[1];
aph = a.anchorPoint[1];
aph2 = (h/2) - (aph*-1);

maskh = (h*sh/100);
masky = (a.transform.position[1]) - aph2;

thisy = masky + (maskh/2);

//--- X ----

w = a.width;
sw = a.transform.scale[0];
apw = a.anchorPoint[0];
apw2 = (w/2) - (apw*-1);

maskw = (w*sw/100);
maskx = (a.transform.position[0]) - apw2;

thisx = (maskx + (maskw/2)) + effect("Slider X")("Slider");

[thisx, thisy]


Return to posts index

Dan Ebberts
Re: Problem with linking correct layer.pos to pos/scale of above layer
on Aug 19, 2016 at 5:17:50 pm

Like this maybe:

a = thisComp.layer(index - 1);
p1 = a.toComp([a.width,a.height]/2);
p2 = toComp([width,height]/2);
value - (p2 - p1)


Dan



Return to posts index

Jeremiah Batholomis
Re: Problem with linking correct layer.pos to pos/scale of above layer
on Aug 20, 2016 at 9:48:14 am

Thx for the Replay, but it too does only work if the Anchor Point is from zero to negativ.
As soon as the AP-Value is positiv it stops working.

Cheers


Return to posts index


Dan Ebberts
Re: Problem with linking correct layer.pos to pos/scale of above layer
on Aug 20, 2016 at 8:53:29 pm

I must not understand what you're trying to do, because for me, the expression will track the center of layer 1 no matter where its anchor point is.

Dan



Return to posts index

Jeremiah Batholomis
Re: Problem with linking correct layer.pos to pos/scale of above layer
on Aug 22, 2016 at 7:57:21 am

Mmmh ... did you use Scale on layer 1? Because that is when it brakes the solution for me.
Can u upload a AE-Example? Maybe i do something else wrong.

Thx a lot anyway!!


Return to posts index

Jeremiah Batholomis
Re: Problem with linking correct layer.pos to pos/scale of above layer
on Aug 22, 2016 at 10:03:41 am

Hey Dan, i have to correct my previous post. You are 100% right. It works pretty fine and in just 4 lines! Amazing!

The problem was, that we use the (awesome) Motion-Plugin from Mt. Mograph and if you animate scale plus position and then reposition the AP with his plugin, theeeeen (i don't know why, but) it turn into motion from hell ;)

Thx for your help mate!


Return to posts index

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