• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Please help me!

Explorer ,
Mar 06, 2022 Mar 06, 2022

Copy link to clipboard

Copied

@Rick Gerard @Mylenium 

 

I'm trying to dynamically adjust keyframe values, & I'm pretty much successfull. but problem is after effects only catch one linear expression (first & second keyframe can be dynamically change) but not others. how to do that? please help.

 

Screenshot 2022-03-06 210321.png

 

TOPICS
Expressions , Resources , Scripting

Views

2.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 17, 2022 Mar 17, 2022

oh, yes, I forgot  that Ae's linear behaves strange when linear(t,t1,t2,...)  t1 > t2.

Therefore, my expression only works if the value is increasing, not when it is going down.
Does this one work as expected for you?

 

keyValues = [60,40,100,60];

function myLinear(t,tMin,tMax,vMin,vMax) {
if(tMax< tMin){
var temp = tMax;
tMax=tMin;
tMin=temp;
temp=vMax;
vMax=vMin;
vMin=temp;
}
var result = vMin;
if(tMin==tMax){
result = vMin;
}
else {
result= vMin+( (t-tMin)/(tMax-tMin))*(vMax-vMin);
}
return result;
}


val = val

...

Votes

Translate

Translate
Explorer ,
Mar 13, 2022 Mar 13, 2022

Copy link to clipboard

Copied

"Flow" is actually expression interpolation plugin for after effects: Click Here To See Flow Plugin 

 

bu the problem is when i tried custom easing it 's not catch due to Function is not function customBezier(t,tMin,tMax,value1,value2) it's 6 values > function customBezier(t,tMin,tMax,value1,value2,bezierPoints)  Now half of my problem is solved but half is still there: can you solve this?

 

 

/* ---------- Flow Function Declarations ---------- */
function customBezier(t,tMin,tMax,value1,value2,bezierPoints){if(arguments.length!==6)return value;var a=value2-value1;var b=tMax-tMin;var c=clamp((t-tMin)/b,0,1);if(!(bezierPoints instanceof Array)||bezierPoints.length!==4)bezierPoints=[0,0,1,1];return a*h(c,bezierPoints)+value1;function h(f,g){var x=3*g[0];var j=3*(g[2]-g[0])-x;var k=1-x-j;var l=3*g[1];var m=3*(g[3]-g[1])-l;var n=1-l-m;var d=f;for(var i=0;i<5;i++){var z=d*(x+d*(j+d*k))-f;if(Math.abs(z)<1e-3)break;d-=z/(x+d*(2*j+3*k*d));}return d*(l+d*(m+d*n));}}
/* ---------- Flow Function Declarations ---------- */
/* ---------- Flow Expression Template ------------ */
var animationStartTime = 1;
var animationEndTime = 2;
var startValue = value;
var endValue = value * 2;
if (numKeys > 0) {
var nearestKeyIndex = nearestKey(time).index;
if (key(nearestKeyIndex).time > time) nearestKeyIndex--;
if (nearestKeyIndex === 0 || nearestKeyIndex === numKeys) {
startValue = endValue = value;
} else {
animationStartTime = key(nearestKeyIndex).time;
animationEndTime = key(nearestKeyIndex + 1).time;
startValue = key(nearestKeyIndex).value;
endValue = key(nearestKeyIndex + 1).value;
}
}
customBezier(time, animationStartTime, animationEndTime, startValue, endValue, [0.9, 0, 0.56, 0.8]);
/* ---------- Flow Expression Template ------------ */

 

sliderControl = comp("Title 02").layer("Setting").effect("MF - Lines")(1);

if (numKeys > 1){
t1 = key(1).time;
t2 = key(2).time;
t3 = key(3).time;
t4 = key(4).time;
v1 = [25];
v2 = [40];
v3 = [50];
v4 = [70];
if (time < key(2).time)
customBezier(time, t1, t2, v1, v2); else customBezier(time, t2, t3, v2, v3);
if (time < key(3).time)
customBezier(time, t1, t2, v1, v2); else customBezier(time, t3, t4, v3, v4);
} else {
value
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 13, 2022 Mar 13, 2022

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2022 Mar 13, 2022

Copy link to clipboard

Copied

If you're going to use that function, you have to provide the 6th argument, which is a 4-element array that defines the x and  y coordinates of the two bezier handles. I'm guessing the coordinate system defines [0,0] as the start value and [1,1] as the end value, so I'd suggest you try [0.33, 0, 0.67, 1] and see what you get.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 13, 2022 Mar 13, 2022

Copy link to clipboard

Copied

Nope sir no help, I think we have to change function to customBezier(t,tMin,tMax,value1,value2) from customBezier(t,tMin,tMax,value1,value2,bezierPoints)

 

so can we change or alter function to another? I previously gave you "expo" expression. it's catching easing and all values because after effects default interpolation is limited to 3 or 5 but here in customBezier it's exceeds to 6 which is higher... so first we have to make it 5 values... we have to change function to 5 values only then custom Bezier will work i think!  It's very hard but I think you can do it... maybe.... 8)😁

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2022 Mar 13, 2022

Copy link to clipboard

Copied

I don't see any way for the bezier calculation to work without specifying the handles...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 14, 2022 Mar 14, 2022

Copy link to clipboard

Copied

this code is given by you:

 

keyValues = [60,40,100,60];
val = value;
if (numKeys > 0){
  n = nearestKey(time).index;
  if (time < key(n).time) n--;
  if (n < 1){
    val = keyValues[0];
  }else if (n == numKeys){
    val = keyValues[keyValues.length-1];
  }else{
    v1 = keyValues[n-1];
    v2 = keyValues[n];
    val = ease(time,key(n).time,key(n+1).time,v1,v2);
  }
}
val

 

so my idea is if we crate a new layer & use try catch(err) method for catching all the key values and add flow plugin expression there? is it possible?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 14, 2022 Mar 14, 2022

Copy link to clipboard

Copied

I have no idea how try/catch would be useful in this situation...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 14, 2022 Mar 14, 2022

Copy link to clipboard

Copied

Screenshot 2022-03-14 215123.png

 

as you can see two keframes catching easing with values too! (It's limited to two keyframes only, don't know why!) 

So, now the only solution I have is to create same multiple layers & only set two keyframes. Simple! 😁

 

if want to add something new in this, it would be great... otherwise thank you for help me my brother... you all helps me a lot!!! 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 17, 2022 Mar 17, 2022

Copy link to clipboard

Copied

oh, yes, I forgot  that Ae's linear behaves strange when linear(t,t1,t2,...)  t1 > t2.

Therefore, my expression only works if the value is increasing, not when it is going down.
Does this one work as expected for you?

 

keyValues = [60,40,100,60];

function myLinear(t,tMin,tMax,vMin,vMax) {
if(tMax< tMin){
var temp = tMax;
tMax=tMin;
tMin=temp;
temp=vMax;
vMax=vMin;
vMin=temp;
}
var result = vMin;
if(tMin==tMax){
result = vMin;
}
else {
result= vMin+( (t-tMin)/(tMax-tMin))*(vMax-vMin);
}
return result;
}


val = value;
if (numKeys > 0){
n = nearestKey(time).index;
if (time < key(n).time) n--;
if (n < 1){
val = keyValues[0];
}else if (n == numKeys){
val = keyValues[keyValues.length-1];
}else{
v1 = keyValues[n-1];
v2 = keyValues[n];
val = myLinear(value,key(n).value,key(n+1).value,v1,v2);
}
}
val

 

 

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 17, 2022 Mar 17, 2022

Copy link to clipboard

Copied

Yes, this works as expected!!! Thank You very much all my teachers!!!! @Mathias Moehl  @Dan Ebberts  @Mylenium   

 

 

& Wish you all Happy Holi.... Today in our India, we are celebrating "Holi" The festival of colors....

 

May god KRISHNA give you long life, prosperity, wealth, health & all... 🙂 

 

holi-the-festival-of-colors-india-109420836-58e011443df78c51624c663b.jpg

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 18, 2022 Mar 18, 2022

Copy link to clipboard

Copied

LATEST

You are welcome 🙂

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines