Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions getting multiple objects to stay between two nulls…

  • getting multiple objects to stay between two nulls…

    Posted by Jerry Fines on January 15, 2009 at 10:51 pm

    I have two nulls and I’m trying to keep multiple objects between them both. I found this code that does it well for a ‘null 3’:

    p1 = thisComp.layer(“Null 1”).position;
    p2 = thisComp.layer(“Null 2”).position;
    div(add(p1, p2),2);

    the problem is that I’m trying to do it for multiple objects so I thought I could ‘chain’ them, however, this leads things to ‘lock up’. This is my sample code for a ‘null 4’:

    p1 = thisComp.layer(“Null 1”).position;
    p2 = thisComp.layer(“Null 3”).position;
    div(add(p1, p2),2);

    For some reason this new null, null 4, will not simply go between Null 1 and Null 3. I have no idea why not. Is my logic incorrect?

    Will Cavanagh replied 17 years, 4 months ago 3 Members · 3 Replies
  • 3 Replies
  • Jerry Fines

    January 15, 2009 at 11:11 pm

    nevermind, there seems to be something much more dubious going on. the code works in its own comp, but something else in this comp is keeping it from acting normal. sorry.

  • Dan Ebberts

    January 16, 2009 at 12:56 am

    Let’s say you wanted to spread 5 layers between Null 1 and Null 2. I make sure the 5 layers are at the top of the layers stack (Layers 1 through 5) and give them expressions like this:

    numLayers = 5;

    p1 = thisComp.layer(“Null 1”).position;
    p2 = thisComp.layer(“Null 2”).position;

    p1 + (p2 – p1)*(index/(numLayers))

    Dan

  • Will Cavanagh

    January 16, 2009 at 1:33 am

    To add to this, if you need to move your layers to below another n layers (e.g. an adjustment layer)

    numLayers = 5;
    firstIndex = 1; //layers are at the top now

    p1 = thisComp.layer(“Null 1”).position;
    p2 = thisComp.layer(“Null 2”).position;

    p1 + (p2 – p1)*((index-firstIndex+1)/(numLayers))

    You can make this more portable by adding a “Controller” layer, setting the constants in that layer, and then putting the “math” in each layer’s position (or rotation/opacity/whatever) property with references to the sliders on your “Controller” layer for access to the constants (nLayers, startIndex, anything else you need…)

    Then if you make these presets, you can just drag the preset to each layer, and make a new null and add your controller preset each time you need to do this sort of thing…

    Probably more of an answer than you bargained for…

    –Will

    getnmd.com
    nationalboston.com

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