Activity › Forums › Adobe After Effects Expressions › Linking the Scale to Position with Easy Ease and Limitations
-
Linking the Scale to Position with Easy Ease and Limitations
Posted by George Henderson on August 12, 2019 at 4:59 pmHello,
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];Dan Ebberts replied 6 years, 11 months ago 2 Members · 8 Replies -
8 Replies
-
Dan Ebberts
August 12, 2019 at 9:03 pmIs 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
-
George Henderson
August 13, 2019 at 3:44 amThat’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? -
Dan Ebberts
August 13, 2019 at 4:48 amI 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
-
George Henderson
August 13, 2019 at 7:57 pmHi 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!
-
Dan Ebberts
August 13, 2019 at 8:43 pmI 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
-
George Henderson
August 13, 2019 at 10:49 pmDan, you had the answers to every single one of my questions. I’m truly grateful for all your assistance.
Thank you! -
George Henderson
August 14, 2019 at 10:01 pmHello,
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.33if (PN > 1) {PXK=linear(PX.value,PX.key(1).value,PX.key(2).value,100,33.33333); PNS=PX.key(PN).value; if(PNS < 1280) val=[PXK,PXK];}
else
if(PN > 1) {PNS=PX.key(PN).value; if(PNS => 1280) val=[S,S];} -
Dan Ebberts
August 14, 2019 at 10:45 pmIt looks like you have:
if (PN > 1){
followed by :
}else if (PN > 1){
so it will never get to the 2nd one.
Dan
Reply to this Discussion! Login or Sign Up