Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random, Intermittent Wind Gusting – Bending with Pauses

  • Random, Intermittent Wind Gusting – Bending with Pauses

    Posted by Royce Jacobs on January 5, 2023 at 1:32 am

    Hello, I’m working on making a tree sway in the wind in a realistic manner with expressions, so it can be applied to many without manual keyframing required. I’m using CC Bend It and am trying to get it to simulate gusts of wind that come only periodically.

    I found an old Dan Ebberts expression that has gotten me part of the way, but what I’m struggling with is how to get the tree to return back to center (zero bend) after each gust, before pausing. (Also trying to understand the % percent sign operator) Any help would be appreciated!

    moveMin = 0.5; // minimum move time (initial wind gust)
    moveMax = 1; // maximum move time
    moveBackMin = 1.5; // minimum move time to return to zero (slower than the initial gust)
    moveBackMax = 2; // maximum move time to return to zero
    pauseMin = 1; // minimum pause time
    pauseMax = 2; // maximum pause time
    minVal = -20; // minimum move amount <-
    maxVal = 20; // maximum move amount ->
    seedRandom(index,true); // set pre-run for endT
    endT = - random(moveMax);
    j = 0;
    k = 0;
    while ( time >= endT){
    j += 1;
    seedRandom(j,true);
    startT = endT;
    if (j%2){
    endT += random(moveMin,moveMax);
    k++;
    }else{
    endT += random(pauseMin,pauseMax);
    }
    }
    if (j%2){
    seedRandom(k,true);
    endVal = random(minVal,maxVal);
    seedRandom(k-1,true);
    startVal = 0;
    ease(time,startT,endT,startVal,endVal);
    //ease(time+endT,startT+endT,endT+endT,endVal,0);// Return to zero?
    }else{
    seedRandom(k,true);
    random(minVal,maxVal)
    }
    Royce Jacobs replied 3 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    January 5, 2023 at 8:04 am

    Something more like this maybe:

    moveMin = 0.5; // minimum move time (initial wind gust)
    moveMax = 1; // maximum move time
    moveBackMin = 1.5; // minimum move time to return to zero (slower than the initial gust)
    moveBackMax = 2; // maximum move time to return to zero
    pauseMin = 1; // minimum pause time
    pauseMax = 2; // maximum pause time
    minVal = 20; // minimum move amount <-
    maxVal = 40; // maximum move amount ->
    seedRandom(index,true);
    initialDelay = random(pauseMin,pauseMax);
    move = moveBack = val = 0;
    seed = 1001;
    t = tPrev = inPoint+initialDelay;
    while (t <= time){
    seedRandom(seed,true);
    val = random(minVal,maxVal);
    move = random(moveMin,moveMax);
    moveBack = random(moveBackMin,moveBackMax);
    pause = random(pauseMin,pauseMax);
    tPrev = t;
    t += move+moveBack+pause;
    seed++;
    }
    d = time - tPrev;
    if (d < move)
    ease(d,0,move,0,val)
    else if (d < (move + moveBack))
    ease(d,move,move+moveBack,val,0)
    else
    0
  • Royce Jacobs

    January 5, 2023 at 11:45 am

    Ohhh amazing as always Dan, thank you! (Yes I suppose the wind would only be blowing in one direction haha…) Your grasp on time evaluation always bewilders me – It makes me a little cross-eyed, but I’ll be studying this for a while. Thanks again, works perfectly!

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