Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions “Follow the leader” in 2D with Scaling

  • “Follow the leader” in 2D with Scaling

    Posted by Wilhelm Hagberg on July 24, 2009 at 4:31 pm

    Hi,

    Hopefully I don’t get on anyones nerves with my endless Fish animation problems! I got some good advice over at the After Effects forum, but I think I might need a solution involving expressions.

    I have a row of fishes following a complex, spiral-ish 2D path. The fishes are supposed to get smaller and smaller as they approach the center of the animation: Right now I have animated 1 fish, and duplicated and time offset the layers.

    As you can see, as the fishes are getting smaller, the distance between them also gets larger. I want them to have an even distance to each other, like one biting the next one’s tail.

    Because of the fact that the fishes have to fit exactly within the outlines of the coloured areas, I cannot use a 3D path for this animation (the tweaking of the 3D path to match the 2D drawing would take forever). Also, the scaling isn’t linear, i have to use several keyframes to make the size of the fishes match the background. I need some parenting expression that takes the parent’s “scale” value into consideration and that calculates the distance between the fishes from the tail/head rather than from the centers. I have found some interesting stuff here:

    https://www.motionscript.com/mastering-expressions/follow-the-leader.html

    But these scripts are based on a 3D scenario and don’t include the “scaling” parameter.

    Any genius out there that can help me?

    best-

    Wilhelm

    Wilhelm Hagberg replied 16 years, 9 months ago 4 Members · 5 Replies
  • 5 Replies
  • Micheel Leavitt

    July 24, 2009 at 7:45 pm

    this kinda works, but it isn’t really amazing and instant…

    I remade your project kinda using circles and a quickly drawn motionpath. Then I set the anchorpoint to the left-most edge of the circle (y value is still centered) then I figured you keyframed the path, so I wrote this for the follower’s position:

    //apply to duplicated follower layer
    x=thisComp.layer(“Null 1”).effect(“pos offset slider”)(“Slider”)/1000;
    thisComp.layer(index – 1).transform.position.valueAtTime(time – x)

    then I did this for scale of the leader:

    //apply to leader layer
    x = transform.position[0];
    s = ease(x,0,720,100,50);
    [s,s,s]

    then I offset the follower’s scale by .1 according to the leader, and to make them stay close to each other I just went through the timeline and keyframed the null slider for position so that whenever there was a break in the line I would nudge them together (hence the “/1000” at the end) I got them pretty close through the whole thing, so this should do the trick if someone doesn’t have a magical math problem that does it all for you. Hope it helps!

  • Filip Vandueren

    July 25, 2009 at 12:04 am

    I don’t think it’s very easy to achieve with an expression

    however, in this case, you could make a straight line of fish in a precomp, and conform them with a Bezier Warp or a Mesh Warp Then just animate the fish in the precomp.

    f tried this and it’s possible, especially with simple Bezier shapes like your spirals.

  • Wilhelm Hagberg

    July 25, 2009 at 6:09 am

    Thanks a lot guys. Filip, I tried the Bezier warp thing and the result was quite good, although it takes lots of tweaking to make it look nice (not warp-y). I wish there was a way of using the illustrator outlines as boundarys for the warp, instead of having to redraw them within the effect! Micheel, I’m going to try your trick as well during the weekend!

    Many thanks-

    Wilhelm

  • Ryan Hill

    July 28, 2009 at 8:13 pm

    What if you put the anchorpoint in the nose of the fish and then parented each one to the one that precedes it?

    Then the position will take care of itself and you need only to animate the rotation.

  • Wilhelm Hagberg

    August 1, 2009 at 3:37 pm

    thanks, this sounds interesting. i guess in this scenario only the first fish is attached to the path and the other ones dont have any position keyframes ? I understanf the first fish will @drag@ the others behind it, but I don’t understand how the others will follow the path?

    Wilhelm

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