Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Need an expression to automatically position a Light between two tracked Lights.

  • Need an expression to automatically position a Light between two tracked Lights.

    Posted by Tracy Smith on May 23, 2020 at 11:49 am

    Hello everyone,
    I’m not a master of expressions but I’m trying to learn.
    I have a project where I have footage of long fluorescent bulbs moving.
    I need to place After Effects Lights all along the length of the bulbs as they move.
    I’d like to have 5 lights per bulb.
    I have tracked the ends of the bulbs and positioned lights there. I now need to place 3 lights between the two tracked lights. I believe an expression could be written to position a light between the two tracked lights but I’m not sure how to proceed. Ideally I’d like 3 lights between the two tracked lights for a total of 5 lights per bulb. So the expression would need a variable to position a light somewhere along the line between the two tracked ends. If anyone has an idea I would love to hear it. Thank you so much After Effects gurus!

    Walter Soyka replied 6 years, 2 months ago 3 Members · 2 Replies
  • 2 Replies
  • Jason Mckee

    May 24, 2020 at 3:34 pm

    This might help you out.

    https://aescripts.com/malcolm-in-the-center/

    If that one doesn’t work for you then you might be able to get something close with this one. I hope this helps.

    https://aescripts.com/align-3d/

  • Walter Soyka

    May 26, 2020 at 3:16 pm

    Here’s a project that demonstrates the scenario you describe:

    [image]

    14144_stringoflights.aep.zip
    [project file]

    In this setup, I’ve added three Effects Controls to each follower layer:
    1) A Layer Control (renamed to “Beginning”), where I select the line’s beginning point
    2) A second Layer Control (renamed to “End”), where I select the line’s ending point
    3) A slider control (renamed to “Completion”), where I can animate along the line from the beginning to the end

    Each follower layer also has this expression on its Position property. I’ve commented it here to explain what it’s doing. If you have questions, I’d be happy to try to answer them.
    // get our effect controls into some variables we can easily use
    var lA = effect("Beginning")("Layer");
    var lB = effect("End")("Layer");
    // make sure that the completion value scales from 0 to 1
    var completion = linear(effect("Completion")("Slider"), 0, 100, 0, 1);

    // get the positions of the Beginning and End points in world space
    var pA = lA.toWorld(lA.anchorPoint);
    var pB = lB.toWorld(lB.anchorPoint);

    // start the beginning, then add a percentage of the vector from the beginning to the end
    pA + (pB - pA) * completion;

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

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