Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Randomizing Keyframe Destination?

  • Randomizing Keyframe Destination?

    Posted by David Michael on March 6, 2009 at 12:46 am

    Hello, I have a quick (maybe) question about creating randomized destinations for the motion path of an object.

    Currently I have a motion path inside a null (which is the parent of another layer) and inside of that I have an expression that wiggles this position. Pretty easy.

    What I’d like to do now is copy and paste this simple motion over and over, but I’d like for the destination of each copy to be randomized inside of certain parameters.

    This is in terms of the position so let’s just say that the initial keyframe at second 0 is 0,240 and is fixed. The destination keyframe would then be at second 10 and would have the coordinates 600,y where y is random.

    Is there any way to set this up? Maybe something like position.valueattime(10)[1] = random()? Will this then translate into the motion path? (I’m at work so I can’t just test it outright, and want to make sure I’m at least on the right track when I get home)

    Also, I’ve noticed when I copy and past my wiggle layer, the paths created are identical, is there a way to reset the numbers so that the wiggle is random for every layer? Thanks for all of your help!

    Filip Vandueren replied 17 years, 2 months ago 2 Members · 3 Replies
  • 3 Replies
  • Filip Vandueren

    March 6, 2009 at 1:54 am

    Hi David,

    [David Scorca] “Maybe something like position.valueattime(10)[1] = random()? Will this then translate into the motion path?”

    You’re thinking backwards where expressions are concerned. You can’t change the values in a keyframe or in a layer from within an expression. (you can do this with a script which is something else)

    You would have to apply an expression to position that yields the correct result for every frame where it is calculated. Something like this:


    seedRandom(index,true); // seeds the random number to 1 unique random value

    start_pos=[0,240];
    end_pos=[600, random(0,480) ];

    anim=ease(time,0,10,start_pos, end_pos);

    // the difference between the wiggled position and the original position=just the jiggle
    wigg=wiggle(1,50) - value;

    anim+wigg;

    incidentally, using a seedRandom makes sure you get a unique wiggle too.

  • David Michael

    March 6, 2009 at 2:42 am

    Very interesting. I understand basically how you’ve set that up, and this is certainly going to make my world a hell of a lot easier. I’m going to take that code, play with it as soon as I get home and look up all the functions to make sure I understand them inside and out. Basically, what I see is that there are only a few commands ease(), wiggle(), random(), and seedRandom(). And most of the lines are definitions of the arrays and ease() is really the driving force behind this operation, as it is going to draw the line over the 10 seconds, and it’s got the wiggle built in. Before reading your response I didn’t realize variables could be arrays and that will be endlessly useful. Thanks again for your help! If what I end up animating is worthwhile looking at all I’ll make sure to post up a link.

  • Filip Vandueren

    March 6, 2009 at 3:09 am

    Okay,

    also take a look at the other interpolation methods:
    linear() and easeIn() and easeOut()

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