Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Set random value + keyframes

  • Set random value + keyframes

    Posted by Jeff Murchison on October 2, 2012 at 9:00 pm

    It’s been a while since I’ve worked with keyframes, so I’m having a bit of trouble nailing this one down.

    I’ve got an object in 3D space. X and Z coords are fine and shouldn’t change from their set value.

    For the Y value, I want it to be assigned a random number (between, say, -100 and -200) only once, at the beginning. Then it needs to go up to 0 over the course of 20 frames. I’d also like to set the frame that it starts that transition on as a random frame between 0 and 10.

    I’ve got some jumbled up code that I’ve been working on, but I don’t believe it’s worth posting. The part I’m having the issue with is the going up to 0 over the course of 20 frames, and getting the random values to only change once instead of once every frame.

    Edit: Actually, here’s some code:

    seedRandom(30,true);

    posY = random(-85, -385);

    startFrame = Math.floor(random(0,10));
    endFrame = startFrame+20;

    [value[0], posY, value[2]]

    Jeff Murchison replied 13 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    October 2, 2012 at 10:21 pm

    Something like this, probably:

    maxDelayFrames = 11;
    minY = -200;
    maxY = -100;
    rampFrames = 20;

    seedRandom(index,true);
    f = Math.floor(random(maxDelayFrames));
    startY = random(minY,maxY);

    t1 = inPoint + framesToTime(f);
    t2 = t1 + framesToTime(rampFrames);
    y = linear(time,t1,t2,startY,0);
    [value[0],y,value[2]]

    Dan

    Dan

  • Jeff Murchison

    October 3, 2012 at 4:00 pm

    I adjusted it to do easy ease instead of linear and it works excellently. I’ll probably add an offset (slider effect) just in case I need to add a bit of manual control as well, but otherwise it’s perfect. Thanks Dan!

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