ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Linking the Scale to Position with Easy Ease and Limitations

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
George Henderson
Linking the Scale to Position with Easy Ease and Limitations
on Aug 12, 2019 at 4:59:15 pm

Hello,
I have a keyframed object moving from left to right on the X axis with easy ease applied to them.
I'm trying to scale up the object as it goes from point A to B, but I want it to match the position's easing speed and scale up to no more than 15%.
Any help would be greatly appreciated!

p=transform.position[0];
x=transform.scale[0];
y=transform.scale[1];
[x,y];


Return to posts index

Dan Ebberts
Re: Linking the Scale to Position with Easy Ease and Limitations
on Aug 12, 2019 at 9:03:47 pm

Is your position animation 2 keyframes? If so, something like this might work:

p = transform.position;
s = linear(p.value[0],p.key(1).value[0],p.key(2).value[0],0,15);
[s,s]

Dan



Return to posts index

George Henderson
Re: Linking the Scale to Position with Easy Ease and Limitations
on Aug 13, 2019 at 3:44:24 am

That's perfect, it's doing exactly what I was hoping for. Thank you Dan!
Is there anyway to avoid getting errors when there are no keyframes on the layer?


Return to posts index


Dan Ebberts
Re: Linking the Scale to Position with Easy Ease and Limitations
on Aug 13, 2019 at 4:48:23 am

I haven't tested it, but something like this:


p = transform.position;
if (p.numKeys > 1){
s = linear(p.value[0],p.key(1).value[0],p.key(2).value[0],0,15);
[s,s];
}else{
value;
}



Dan



Return to posts index

George Henderson
Re: Linking the Scale to Position with Easy Ease and Limitations
on Aug 13, 2019 at 7:57:30 pm

Hi Dan,
Thank you once again! The code works when it's used outright, but I I'm having trouble implementing it into the script that I'm working on.
Without the no keyframe script, it reads the following:

Y=thisComp.layer("Y2 - L").transform.yPosition; //position of the animated layer (2 keyframes, key1=720 & key2=320)
N=Y.numKeys;
K = value+(Y-Y.valueAtTime(0))/2;
var YY=Y.key(N).value;
if(YY<360){[K];} else {value;}

when I add the condition that there may be no keyframes, the script above fails to function. However, I am able to delete the keyframes without receiving any errors; so the first bit is working. I just don't know how to write: if (keyframes don't exist AND any value smaller than 360) then do {K}.

Y=thisComp.layer("Y2 - L").transform.yPosition;
N=Y.numKeys;
K = value+(Y-Y.valueAtTime(0))/2);

if(N > 1&YY<360) {var YY=Y.key(N).value;[K];} else {value;}

Any ideas how to get the two conditions to work together? Thanks!


Return to posts index

Dan Ebberts
Re: Linking the Scale to Position with Easy Ease and Limitations
on Aug 13, 2019 at 8:43:11 pm

I haven't tested this, but I think it would look like this:


Y=thisComp.layer("Y2 - L").transform.yPosition;
N=Y.numKeys;
K = value+(Y-Y.valueAtTime(0))/2);
val = value;
if(N > 1){
YY=Y.key(N).value;
if (YY<360) val = K;
}
val



Dan



Return to posts index


George Henderson
Re: Linking the Scale to Position with Easy Ease and Limitations
on Aug 13, 2019 at 10:49:04 pm

Dan, you had the answers to every single one of my questions. I'm truly grateful for all your assistance.
Thank you!


Return to posts index

George Henderson
Re: Linking the Scale to Position with Easy Ease and Limitations
on Aug 14, 2019 at 10:01:30 pm

Hello,
I have been trying to get this to work for the last several hours but to no avail. Could you please let me know where the issue is?
It refuses to run the else statement when the value is => 1280.

Error at line 1... Undefined value used in expression (could be an out of range array subscript?)!!!

Thanks!

PX=thisComp.layer("X1 - R").transform.xPosition;
PN = PX.numKeys;
val=value;
S=33.33

if (PN > 1) {PXK=linear(PX.value,PX.key(1).value,PX.key(2).value,100,33.33333); PNS=PX.key(PN).value; if(PNS &lt; 1280) val=[PXK,PXK];}
else
if(PN > 1) {PNS=PX.key(PN).value; if(PNS => 1280) val=[S,S];}


Return to posts index

Dan Ebberts
Re: Linking the Scale to Position with Easy Ease and Limitations
on Aug 14, 2019 at 10:45:02 pm

It looks like you have:

if (PN > 1){

followed by :

}else if (PN > 1){

so it will never get to the 2nd one.


Dan



Return to posts index

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