Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Animating a tree with expressions and no experience at all

  • Animating a tree with expressions and no experience at all

    Posted by Ismael De diego on August 26, 2007 at 10:45 am

    Hi charming people. First i want to explaing that i have no scripting knowledge whatsoever, i mean not a clue, i just discovered this amazing option. So it will help a little bit of pitty and a lot of help. I am trying to animate a tree with many branches and i want them to move like if the wind was blowing. Each branch is a diferent layer and they are correctly parent and anchor pointed so they move with the hierarchy being the stem the most rigid element on the comp . To achive that i create a null object and using the motion sketch and move it horizontaly simulating a wind dinamic on the x axis. Then i went on the stem rotation and activated the script function and with the pickwhip and
    linked to the x position on the null object. Later i repositioned the null object so the moving of the tree rotated in the right position and added a / function at the end so it could simulate a more rigid element, and variying
    through the branches i t create diferent levels o inflexibility on some branches. Resulting in this very elemental stuff:

    thisComp.layer(“Null 3”).transform.position[0]/50

    So far so good, but it looks to mechanic and i wanted to added a litle delay on the branches so each one respond to the wind in a diferent way. I already did it converting the expression to keyframes and movet in time and looked good but i need the expression. I have try a lot of things but i am really lost on this. I will learn the sacred magic of cripting and devote my live in to this. But right now i am totaly blank. Thanks.

    Tyler Egeto replied 18 years, 8 months ago 3 Members · 9 Replies
  • 9 Replies
  • Mike Clasby

    August 26, 2007 at 9:17 pm

    There is an element of Delay in Dan’s expressions on Trails, here:

    https://www.motionscript.com/mastering-expressions/follow-the-leader.html

    Maybe you could use the “index -1” part (in line 2) and add in your own multiplying factor and incororate that into your expression.

    “index -1” refers to the order in the stack.

    Anyway it sounds like you’re off to a flying start.

    I followed your instructions and I think I would go about it in a slightly different manner.

    Instead of using the position, I tied them all to the Nulls rotation, with Dan’s Expression, on Rotation:

    delay = 5; //number of frames to delay

    d = delay*thisComp.frameDuration*(index – 1);
    thisComp.layer(1).rotation.valueAtTime(time – d)

    The above is for the branches on the left side (2D looking at the screen), for the branches on the right side I added a minus sign in front of the last line, making it:

    – thisComp.layer(1).rotation.valueAtTime(time – d)

    Then I wiggled the Null, with a wiggle expression on it’s rotation:

    wiggle(1,20)

    So you end up with a nice fluid waving of the branches, and they’re layer order (index-1) determines who follows who.

    I’m glad you asked the question, it looks useful.

  • Mike Clasby

    August 26, 2007 at 9:26 pm

    In the expression I used, the Null needs to be the top layer, all those with the expression follow the top layer. To make it refer to the Null specifically, change the last line to:

    thisComp.layer(“Null 1”).rotation.valueAtTime(time – d)

  • Mike Clasby

    August 26, 2007 at 10:30 pm

    OK, you’ve officially created a Monster… Me… I took your tree to another level.

    Overview: I added Bender to each branch, tied that to rotation of that layer to get bending branches. I also tied all the branches to the Trunk (by making it layer 1, the top layer in the expression last post).

    Details: Bender

    Bender:
    Effect>Distort>CC Bender
    place the Top at the tip of the branch, the Base at the base of the branch.
    Then for Amount I pickwhipped to the layer’s rotation to get the expression (on Amount):

    rotation

    So the rotation of the branch causes the branch to bend or whip as the branch rotates.

    I had to also ad the effect Grow Bounds (at about 50) because my branches were just solids and Bender made then bend off the layer and disappear without the Grow Bounds.

    Details: Trunk instead of Null

    To tie the branch movement to the Trunk, I put the trunk layer at the top of the stack (I’m using the ” thisComp.layer(1)” in the last line). Then I wiggled it slowly, with this on the trunk’s rotation:

    wiggle(1,5)

    I then modified the branch expressions a bit, to this (still on rotation of the branch layers):

    delay = 5; //number of frames to delay
    whip = 3; // whip factor
    d = delay*thisComp.frameDuration*(index – 1);
    thisComp.layer(1).rotation.valueAtTime(time – d)*whip

    The “whip” in line 2 is a stiffness factor, the lower the stiffer.

    Or try this to make a random whipfactor:

    delay = 5; //number of frames to delay
    seedRandom(0,true);
    whip= random(2,4); // stiffness factor

    d = delay*thisComp.frameDuration*(index – 1);
    thisComp.layer(1).rotation.valueAtTime(time – d)*whip

    For random stiffness between 2 to 4.

    I saved all three bits for the left branch; Grow Bounds, Rotation expression and Bender, by selecting them and saving as an animation Preset (Animation>Save Animation Preset). I named it LeftBranch, and can now apply it enmass to all left branches at once (Select all left Branches, Animation>Apply Animation preset). I did another preset for all right branches.

    Remember: For RightBranches, the last line of any of the rotation variations need a minus sign in front of it, like this:

    – thisComp.layer(1).rotation.valueAtTime(time – d)*stiff

    Also, if you don’t want the trunk to move, just tie them all back to our Null and rotate that.

    Also, if you don’t make Presets you can still apply expressions enmass, by selecting the expression in one layer, Edit>Copy Expression Only, then selecting as many other layers as you want, and then Paste.

    The expressions were modified from Dan expressions linked in earlier posts above (Trails and Random).

    OK, I’m going to go take my meds now, but for I get too far out on a limb…

  • Mike Clasby

    August 26, 2007 at 10:33 pm

    You’ll probably need to make slight adjustments to Bender’s Top and Base for each branch.

    I going to take a nap now.

  • Ismael De diego

    August 27, 2007 at 8:35 am

    Thanks a lot my friend !! i just read your reply and i am going to force myself to understand it. I am in a very primitive stage right now and it seems advanced. But MANY MANY THANKS FOR YOUR TIME. I hope your snap was reparing.

  • Tyler Egeto

    August 28, 2007 at 2:34 pm

    hey guys, This is an interesting thread. By adding CC bender on there you would get a nice look to the tree. I would love to see s small clip, or even a screen capture of what this looks like. I am going to explore this further as well. This is a great experiment.

  • Mike Clasby

    August 28, 2007 at 8:18 pm

    Here’s a render (QT H265 codec):

    https://media.putfile.com/TreeWhipWithExpressions

    Here’s a screenshot of the timeline window.

    https://www.putfile.com/pic.php?img=6441499

    The branches on the left (looking at the screen) have rotation expressions and CC Bender. The Trunk and the branches on the right are without Bender.

    Layer “Left 1” is the topmost left branch, r1, top right.

    Warning: Don’t walk in the woods when the wind is blowing this hard… they don’t call them windomakers for nothin’.

  • Tyler Egeto

    August 28, 2007 at 9:04 pm

    The bender adds a lot to the movement. I am working on a tree animation as well, my tree has layers of branches that off shoot of each other and get smaller. Unfortunately when applying Bender you run into a problem if it bends the branches too far. This is because it you can then see the gap between the layers where they were normally overlapping.

    Over all this is turning out to be an interesting experiment.

  • Tyler Egeto

    August 28, 2007 at 9:16 pm

    Here’s a short video of mine. (It’s not very pretty)

    https://bigbert.vfs.com/~dd09tyler/experiments/tree.mov

    You can see the gaps start to show up between some branches, this is the result of Bender.

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