Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Leaf falling expression (how do i get it to delay?)

  • Leaf falling expression (how do i get it to delay?)

    Posted by Simon Roberts on May 13, 2008 at 4:46 pm

    Hi

    i adapted one of Dan Ebberts tutorials to make a leaf fall from a tree. i’m really happy with it but i need it to start later than right at the beginning… and i’m having trouble doing that.

    I’ve posted the expressions below.

    i’m quite new to AE expressions… any help will probably save me hours of trying to struggle with it myself.

    Thanks

    Simon

    so this is what i have…

    there is a null layer and on the image of the leaf there are these expressions…

    The Point Effect (renamed ‘Life’)

    lmin = 1.5; //minimum particle life
    lmax = 3; //maximum particle life

    seed_random(1,true);
    life=random(lmin,lmax);
    birth=0;
    [birth,life]

    Postition

    gmin=20; //gravity
    gmax=70;
    w=20; //wind
    wdir=0; //wind direction (0 = from left)
    vmin=100; //minimum initial velocity
    vmax=300; //maximum initial velocity
    amin=30; //minimum launch angle from vertical
    amax=120; //maximum launch angle from vertical
    d=2; //drag coeffecient

    birth=effect(“life”).param(“Point”)[0];
    life=effect(“life”).param(“Point”)[1];
    origin=[position[0],position[1],position[2]];
    age=time-birth;
    seed_random(1,true);
    s=random(vmin,vmax);//initial speed
    g=random(gmin,gmax);
    v_e=this_comp.layer(“Null 1”).position.velocity_at_time(birth); //emitter velocity
    a=degrees_to_radians(random(amin,amax)); //angle from vertical
    r=degrees_to_radians(random(360)) //rotation around y axis
    x=s*Math.sin(a)*Math.cos(r);
    y=-s*Math.cos(a);
    z=s*Math.sin(a)*Math.sin(r);
    v=[x,y,z]+v_e;
    new_speed=length(v);
    unit_v=normalize(v);

    if (d>0){
    delta_p=new_speed*(1-Math.exp(-d*age))/d;
    }else{
    delta_p=age*new_speed;
    }
    delta_w=w*age;
    delta_g=g*age*age/2;

    wa=degrees_to_radians(wdir);

    origin + delta_p*unit_v + [delta_w*Math.cos(wa),0,delta_w*Math.sin(wa)] + [0,delta_g,0]

    Orientation

    rmax=0;
    rmin=-0;
    birth=effect(“life”).param(“Point”)[0];
    life=effect(“life”).param(“Point”)[1];
    age=time-birth;
    if (life==0){
    [0,0,0]
    }else{
    seed_random(birth,true);
    init_orient=random([360,360,360]);
    final_orient=(init_orient);
    init_orient +(final_orient-init_orient)*(age/life)
    }

    X Rotation

    rmax=360; //maximum rotation
    rmin=-360; //minimum rotation

    birth=effect(“life”).param(“Point”)[0];
    seed_random(1,true);
    r=random(rmin,rmax);
    life=effect(“life”).param(“Point”)[1];
    age=time-birth;
    if(life==0){
    0
    }else{
    r/life*age
    }

    Y Rotation

    rmax=360; //maximum rotation
    rmin=-360; //minimum rotation

    birth=effect(“life”).param(“Point”)[0];
    seed_random(1,true);
    r=random(rmin,rmax);
    life=effect(“life”).param(“Point”)[1];
    age=time-birth;
    if(life==0){
    0
    }else{
    r/life*age
    }

    Z Rotation

    rmax=360; //maximum rotation
    rmin=-360; //minimum rotation

    birth=effect(“life”).param(“Point”)[0];
    seed_random(1,true);
    r=random(rmin,rmax);
    life=effect(“life”).param(“Point”)[1];
    age=time-birth;
    if(life==0){
    0
    }else{
    r/life*age
    }

    Simon Roberts replied 18 years ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    May 13, 2008 at 8:06 pm

    I think all you need to do is change the birth variable in the point control expression and then add some code to each of the other expressions that checks to see if the current time is less than birth, in which case the expression does nothing.

    Here’s an example of a random birth expression for the point control:

    bmin = 0; // minimum birth time
    bmax = 4; // maximum birth time
    lmin = 1.5; //minimum particle life
    lmax = 3; //maximum particle life

    seed_random(1,true);
    life=random(lmin,lmax);
    birth=random(bmin,bmax);
    [birth,life]

    And here’s the z rotation expression modification to get you started:

    Z Rotation

    rmax=360; //maximum rotation
    rmin=-360; //minimum rotation

    birth=effect(“life”).param(“Point”)[0];
    seed_random(1,true);
    r=random(rmin,rmax);
    life=effect(“life”).param(“Point”)[1];
    if (time >= birth){ //***** this is new
    age=time-birth;
    if(life==0){
    0
    }else{
    r/life*age
    }
    }else{ // **** this is new
    value // **** this is new
    } // **** this is new

    Dan

  • Simon Roberts

    May 13, 2008 at 10:59 pm

    ah…. amazing!

    thats perfect.

    thanks very much!

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