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 automate cards stacking up

  • Need an expression to automate cards stacking up

    Posted by Riccardo Sinti on July 21, 2005 at 8:00 pm

    I have 90 “cards” I want to fall from off screen and stack up one upon another in a natural way.
    I need an expression that will make each card follow the other, rotate in z randomly so they look random,
    and do so in 1 second increments. A nice natural float down would be nice too.
    Any suggestions?

    Thanks

    Skacey replied 20 years, 10 months ago 4 Members · 7 Replies
  • 7 Replies
  • Riccardo Sinti

    July 21, 2005 at 8:34 pm

    I want one card to follow the previous card in x,y,z dimension but end up -1 in the z axis.

    I thought I knew how to do this but it is not working.

    thisComp.layer(“Layer 1”).[position[0], position[1],position[2-1]]

    Why doesn’t this work?

    I have the comp, the layer then the 3 value array.

    So just an even more basic question, how do I write out the full expression with the x,y,z array for position and not just

    thisComp.layer(“Layer 1”).position

    For some reason I just can’t get my head around exprssions all the time. I wish someone would do a seminar or weekend course on just expressions!

  • Dan Ebberts

    July 21, 2005 at 9:13 pm

    If you just want to subtract 1 from the layer’s z value you could do it like this:

    thisComp.layer(“Layer 1”).position – [0,0,1]

    The easiest way to express a value as the three individual coordinates would be to do something like this:

    p = thisComp.layer(“Layer 1”).position;
    [p[0],p[1],p[2]]

    It’s all just JavaScript array notation.

    Dan

  • Filip Vandueren

    July 21, 2005 at 9:18 pm

    Hi,

    try this:
    Animate the first layer complete with a ease on the first key-frame to simulate gravity.

    then give all the next layers these expressions:

    Position:

    thisComp.layer(index-1).position.valueAtTime(time-0.8) - [0,0,index];

    Z-Rotation;

    seedRandom(index, timeless = true);
    random(-10,10)

    For position, it follows the previous layer by copying the position it was at 0.8 seconds earlier.
    The Z-rotation, rather obviously, get’s a random value between -10 and +10.

  • Riccardo Sinti

    July 21, 2005 at 10:12 pm

    Thank you so much.
    That position expression does the trick but there are problems:
    1. with 90 layers it become a render hog, but I can deal with that.
    2. the second card is indexed to the first -1 in the z position, but by layer 90 the position gets offset by -90 in z compared to layer 89.
    so that the stack becomes very tall! In otherwords, the distance between layer 3 and two is more than 2 and 1 and so on until layer 90 gets stacked way far from layer 89.
    I would like them all to stack the same distance from eachother, as if they were lying on top of one another.

  • Riccardo Sinti

    July 21, 2005 at 10:25 pm

    How do i amend the expression

    thisComp.layer(“Layer 1”).position – [0,0,1]

    to delay the layer from folowing?

    I have this saved biut don’t know how to use it:

    value_at_time(time-this_comp.frame_duration)

  • Filip Vandueren

    July 21, 2005 at 10:48 pm

    Sorry, a little error in my logic there,
    just use [0,0,1] or even less.

  • Skacey

    July 24, 2005 at 5:21 pm

    I needed to do this same thing and ended up writing a fairly complicated solution.

    Some items to remember –

    1. You don’t need to offset the landing location by 1 – you can do it with 0.2 or so making the final stack much shorter. (I used one but you only need a slight offset to make it render above the last card)
    2. Using the 3D drop shadow and linking the Distance, Opacity, and Feathering to the Z position will make it much more believable with a shadow that starts farther away, highly feathered and with blurred edges and moves to just under the card at about 60% opacity and a slight blur on the edges. This will REALLY slow the render down but the effect is fantastic.
    3. Using the seed random feature tied to the starting time parameter is a great way to vary the start and end positions and rotations. Then by offsetting each layer in time you will get cards that start to fall one second apart and land neatly scattered on the table.
    4. once you have what you want make sure to save it as a preset so you can quickly apply it later if needed.

    -Scott Kacey

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