Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Linking separate layers & properties – using expression and slider control

  • Linking separate layers & properties – using expression and slider control

    Posted by Theo Williams on August 13, 2015 at 10:26 am

    Hey guys,

    Having trouble simplifying a SAT NAV (GPS) animation for multiple map deliveries.

    Ive drawn a shape layer path and used a trim path to animate a dashed line.

    Ive used the same path to create position data for a car that goes round the map and have the animations matching all fine.

    My problem comes from trying to sync this animation to some VO taking us through the drive – So far ive pre composed my animation and used time-remapping to sync the car with the VO (all well and good but this requires a fair few key frames and is adding an annoying amount of time to what is looking to be around 50 different map runs)

    I need a way to link the position of the car (an AI file – but could be PNG//whatever) to the end of my trim path and control the speed it reaches its destination with a nice easy to use slider control

    What im using at the moment makes the line complete the enitre journey at .o1% and the car finishes around 27% – so i cant be too far off right – right?

    Its driving me crazy
    (ba dum chhhhhh)

    Any help would be greatly appreciated

    Theo Williams

    ctrl = thisComp.layer("ControlNull");
    slider = ctrl.effect("Slider Control")("Slider");
    n = Math.max(1,Math.min(slider,numKeys));
    valueAtTime(key(Math.floor(n)).time)

    Theo Williams replied 11 years, 1 month ago 3 Members · 3 Replies
  • 3 Replies
  • Kalleheikki Kannisto

    August 13, 2015 at 3:50 pm

    Hi Theo,

    The ideal setup would be that the slider going from 0 to 100 would match up to the progress along the path.

    After some digging into several of Dan Ebberts’ examples of similar type, here’s what you can do:

    The position expression uses the length of the full animation along the path. The default when you paste a path is 2 seconds, but I’ve stretched it to 12 seconds which is the length of my animation test. You can leave it at the default, but make sure that the first figure in the expression is the length of the animation in seconds.

    I discovered that adding this expression to the position value messes up the auto-orientation. So you have to turn auto-orientation off and use an expression to generate a custom autorotation.

    Then attach the trim path end value to the same slider, and everything will be synced. Now you can keyframe the slider and the car and the path will follow.

    Position:
    valueAtTime(12/100*thisComp.layer("control").effect("progress")("Slider"))

    Rotation:
    if(time<=0.1) {
    p1 = transform.position;
    p0 = transform.position.valueAtTime(time+.1);
    vect = p1-p0
    }else{
    p1 = transform.position;
    p0 = transform.position.valueAtTime(time-.1);
    vect = p0-p1}
    value+radiansToDegrees(Math.atan2(vect[1],vect[0]))

  • Dan Ebberts

    August 13, 2015 at 3:50 pm

    In general, if you want a layer’s position to track a Trim Paths End percentage, you can paste the path into the layer’s position property and then add a position expression like this:

    e = thisComp.layer(“Shape Layer 1”).content(“Shape 1”).content(“Trim Paths 1”).end;
    valueAtTime((e/100)*2)

    Dan

  • Theo Williams

    August 13, 2015 at 5:14 pm

    You guys are awesome!

    I had just tried building the anim so it played out inside a 10sec pre comp – then i used this expression on said pre comp’s time remapping

    thisComp.layer(“Null 1”).effect(“Slider Control”)(“Slider”)/10

    Buuuuuurt….

    Dan you absolute legend that is a very tidy and fast way of doing this that i shall most certainly be using

    What a good forum – thank you guys very much

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