Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Spacing between layers

  • Spacing between layers

    Posted by Brian Holzknecht on November 6, 2019 at 2:01 am

    So I have a pretty basic setup, I just have a bunch of layers lined up and have a slider control to control spacing, but what I also want, is an additional slider control to control spacing of every 3rd layer, and I’m not sure how to go about that. Here is the current expression I have on all the layers position.

    Thanks,

    Brian

    xPos = thisComp.layer("expression").effect("location")("Point")[0];
    yPos = thisComp.layer("expression").effect("location")("Point")[1];

    spacing = thisComp.layer("expression").effect("spacing")("Slider");

    [(xPos)+((index-1)*spacing), yPos]

    Jakob Wagner replied 6 years, 7 months ago 2 Members · 3 Replies
  • 3 Replies
  • Jakob Wagner

    November 6, 2019 at 11:39 am

    Hi Brian

    Try this:

    layerIndex = (index-1);

    xPos = thisComp.layer("expression").effect("location")("Point")[0];
    yPos = thisComp.layer("expression").effect("location")("Point")[1];

    spacing = thisComp.layer("expression").effect("spacing")("Slider");
    groupSpacing = thisComp.layer("expression").effect("group spacing")("Slider");
    groupSize = thisComp.layer("expression").effect("group size")("Slider");

    layerSpacing = Math.floor(layerIndex/groupSize)*groupSpacing + layerIndex*spacing;

    [xPos+layerSpacing, yPos];

    I have added a couple more sliders. If you want you can simply set groupSize to 3, but I thought it was fun to have it as a slider.

    All the best
    Jakob Wagner

  • Brian Holzknecht

    November 6, 2019 at 5:13 pm

    Thanks Jakob,

    That worked perfectly and much simpler than I thought it would be. Much appreciated.

    Brian

  • Jakob Wagner

    November 6, 2019 at 5:35 pm

    You’re welcome. 🙂

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