Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Control Z Position of multiple Layers with one controller

  • Control Z Position of multiple Layers with one controller

    Posted by Marcel Schobel on June 9, 2020 at 7:58 am

    Hey Guys and Gals…
    i try to do the following:

    i have a grid of letters (all 3D layers) ..evenly distributed all over the screen… z Position is 0 …
    now i would love to have an expression that allows me to change the z Position for all layers randomly … so when i change one value (in a slider maybe) the letters move in Z …without jumping every frame …
    i have come to a dead end with my limited expression knowledge …
    i would appreciate any help
    m.

    Marcel Schobel replied 5 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Robert Müller

    June 9, 2020 at 10:36 am

    Hey Marcel, this should do what you are looking for:

    fac=thisComp.layer("ctrl").effect("factor")(1) //slider on a Null layer
    x=value[0];
    y=value[1];
    rdmMin=-100; //Min random value
    rdmMax=100; //Max random value
    rdmSeed=123456 //random seed
    seedRandom(rdmSeed, timeless = true); //timeless is true, so the value doesnt update every frame
    rdmVal=random(rdmMin, rdmMax);
    z=rdmVal*fac;
    [x,y,z]

    Now when you animate your slider on the control layer from 0 to 1 the layers will start moving up to their random z position. You can increase this if you go beyond 1.
    If this is not random enough you could always factor each layers index into the seed, so you would have a individual seed for every layer. If you want a more natural random distribution you could use “gaussRandom()” instead of “random()”

  • Marcel Schobel

    June 9, 2020 at 11:16 am

    Thank you Sir !
    this does the trick. I am pretty solid at After Effects in all areas EXCEPT for Expressions. I wish i could wrap my head around that. I can even understand/interpret your expression (kind of) BUT i just cannot come up with one myself … i will try to learn in the next couple of weeks …been neglecting expressions for way too long.
    thanks again for your time and kindness
    regards

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