Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Trigger keyframe from another layer’s keyframes (and halfway in between) and map to slider values

  • Trigger keyframe from another layer’s keyframes (and halfway in between) and map to slider values

    Posted by Joe Castiglioni on March 20, 2019 at 1:14 pm

    Okay I know what I would like to do , I just don’t quite know how to get the expression language to do it. This animation involves a ribbon of particles following an arrow connecting 2 points on a map. I want to taper the size of the particle stream so it’s larger in the middle. I’ve got keyframes set up to do this now, but if I could replace those keyframes with an expression it could save a lot of time moving keyframes later and allow me global control of those taper values.

    Here’s what I want:

    If Position keyframe of layer below this layer is keyframe #1, particle emitter size=“beginning size” slider value from control layer

    If position keyframe of layer below this layer is keyframe #2, particle emitter size=“end size” slider value from control layer

    At the time halfway between keyframe #1 and keyframe #2 on the layer below this layer, the particle emitter size=“middle size” slider value from control layer

    Does that make sense? Seems like it should be possible but I don’t have my mind wrapped around how to make it happen. If anyone could has ideas for me I’d greatly appreciate it!

    Joe Castiglioni
    Video Person

    Tomas Bumbulevičius replied 7 years, 1 month ago 2 Members · 3 Replies
  • 3 Replies
  • Tomas Bumbulevičius

    March 20, 2019 at 3:45 pm

    Hey Joe,

    try applying this below to Size expression.

    Few notes:
    1. This is assuming your ‘Montana Arrow’ has two keyframes for position. If not – change key index accordingly.
    2. Animation is based on X position change.
    3. Change ‘startSize’, ‘middleSize’ and ‘endSize’ to affect the size. Ideally, link them to sliders for global control over things.
    4. Animation half point is in the middle of position transformation.

    animRef = thisComp.layer("Montana Arrow").transform.position;
    startKeyIndex = 1;
    endKeyIndex = 2;
    animStartTime = animRef.key(startKeyIndex).time;
    animEndTime = animRef.key(endKeyIndex).time;
    animMiddleTime = animStartTime + (animEndTime - animStartTime)/2;

    animStart = animRef.key(startKeyIndex).value[0];
    animEnd = animRef.key(endKeyIndex).value[0];
    animMiddle = animRef.valueAtTime(animMiddleTime)[0];

    startSize = 2;
    middleSize = 6;
    endSize = 10;

    if (time <= animMiddleTime){
    ease(animRef[0], animStart, animMiddle, startSize, middleSize)
    }else{
    ease(animRef[0], animMiddle, animEnd, middleSize, endSize)
    }

    Find out more:
    After Effects Tutorials: motion design, expressions, scripting.

  • Joe Castiglioni

    March 20, 2019 at 5:22 pm

    Thank you SO MUCH for replying. I was able to make this work exactly how I wanted! I got an error and fiddled around and had to switch the order of the elements in the ease array in the if/else section for some reason, but it totally works!

    Where would you recommend going to learn more about how to think about creating expressions?

    Joe Castiglioni
    Video Person

  • Tomas Bumbulevičius

    March 20, 2019 at 8:03 pm

    You are welcome, Joe! In order to get a grasp of expressions, firstly I would recommend to check these . You will get a general sense of scope possible with expressions and then it is just a matter of implementing solutions (not to forget a tiny bit of programming knowledge essential needs)

    Cheers!

    Find out more:
    After Effects Tutorials: motion design, expressions, scripting.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy