Skip to main content
Participant
October 14, 2020
Question

2 expressions in the one property

  • October 14, 2020
  • 1 reply
  • 250 views

Hi. Simple animation with scale, 2 keyframes: 

1st - 0%, 0%

2nd - 100%, 100%

 

I want to add bounce effect and control the keyframe values via point control. But for some reason the point control doesn't work.

 

Expressions I used:

 

if (numKeys > 1){
t1 = key(1).time;
t2 = key(2).time;
v1=effect("Scale IN")("Point");
v2=effect("Scale OUT")("Point");
linear(time, t1, t2, v1, v2);
}else value


amp = .06;// The higher the value, the greater the amplitude
freq = 2;// The higher the value, the higher the frequency
decay = 5;// The higher the value, the smaller the delay

n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}
}
if (n == 0){
t = 0;
}else{
t = time - key(n).time;
}
if (n > 0){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
value;
}

 

 

This topic has been closed for replies.

1 reply

Mylenium
Legend
October 14, 2020

You need to replace the "value" bits in the second expression with the results of your linear() function from the first expression. Define a custom variable and substitute it. You might want to actually read the help on expressions to get an understanding how they work, not just copy & paste code bits from the Internet...

 

Mylenium

alisunhAuthor
Participant
October 14, 2020

Thanks a lot! I've changed the 2nd expression and it works. Awesome!

 

if (numKeys > 1){
t1 = key(1).time;
t2 = key(2).time;
v1=thisComp.layer("Text").effect("Point Control")("Point");
v2=thisComp.layer("Text").effect("Point Control 2")("Point")
linear(time, t1, t2, v1, v2);
}else value

amp = .06;
freq = 2;
decay = 5;
val = linear(time, t1, t2, v1, v2);

n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}
}
if (n == 0){
t = 0;
}else{
t = time - key(n).time;
}
if (n > 0){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
val + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
val;
}