Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random Scale Up (for multiple objects)

  • Random Scale Up (for multiple objects)

    Posted by Simon Roberts on April 22, 2008 at 9:20 pm

    hi,

    i need to write an expression that will scale up an object (to 21% in this case) at a random time between 2 and 5 seconds. (so i can use it many times)

    the expression below does that but it keeps moving the scale after it’s reached 21% but i want it to stop when it’s reached it’s max scale.

    how do i do this?

    thanks for you’re help.

    max_scale=21; //maximum scale
    smax=5; //scale ramp-up time
    smin=2;
    s=random(smin,smax);

    life=effect(“life”).param(“Point”)[1];
    age=time-effect(“life”).param(“Point”)[0]; //age=time-birth
    if (age

    (that might be quite messy code?!)

    Simon Roberts replied 18 years ago 2 Members · 3 Replies
  • 3 Replies
  • Simon Roberts

    April 22, 2008 at 9:41 pm

    oh yeah…

    effect(“life”).param(“Point”)[1]

    relates the effect “point control” that has been renamed “Life” that has it’s own expression (that generate two numbers… x=0 and y=between 1.5 & 3) that also powers some other expressions as well as scale.

    thanks… any help would be fantastic!

    sorry if that’s not very clear… i’m quite new to expressions

  • Darby Edelen

    April 22, 2008 at 11:50 pm

    [Simon Roberts] “max_scale=21; //maximum scale
    smax=5; //scale ramp-up time
    smin=2;
    s=random(smin, smax);

    life=effect(“life”).param(“Point”)[1];
    age=time-effect(“life”).param(“Point”)[0]; //age=time-birth
    if (age
    x=(age/s)*max_scale;
    [x,x,100]
    }else{
    [max_scale,max_scale,max_scale]
    } “

    If that is exactly the way your code is entered, your if() statement isn’t doing anything. Also, your random ‘s’ value is re-evaluating at every frame, so you may want to seed a ‘timeless’ random.

    Try this instead:


    max_scale=21; //maximum scale
    smax=5; //scale ramp-up time
    smin=2;
    seedRandom(index, true);
    s=random(smin,smax);

    life=effect("life").param("Point")[1];
    age=time-effect("life").param("Point")[0]; //age=time-birth

    x = linear(age, 0, s, 0, max_scale); //If 'age' is ever greater than or equal to 's' then 'max_scale' will be returned thanks to the magic of the linear() function!
    [x,x,x];

    Emphasis is added where I changed your code.

    Darby Edelen
    Lead Designer
    Left Coast Digital
    Santa Cruz, CA

  • Simon Roberts

    April 23, 2008 at 12:52 am

    thats brilliant… it works just as i wanted. it’s funny how you can try and work stuff out for hours and then someone who knows about these things comes along and can write the code in a few seconds.

    thanks again

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