Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions random movement at a certain keyframe

  • random movement at a certain keyframe

    Posted by Will Gan on December 9, 2014 at 6:26 am

    well the title isn’t accurate, what i want is, for example, assuming there are 3 keys, one for initial, one for peak and one for end (could be back to initial position), i want key 1 and 3 to be at fixed position while key 2 needs to be random with a specific range, so if there are 3 objects they will reach random position at key 2

    so

    object 1 at key 1 is at (0, 10), for key 2 it will move to (0, const+random range)

    if you guys get that?

    David Conklin replied 11 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • David Conklin

    December 9, 2014 at 3:12 pm

    Try this. This animates between 2 keyframes and adds a random amount to the second keyframe. You can change the randX and randY variables to fit whatever ranges you want (will pick a random # between the 2 in parentheses).

    The only note, this random # is being generated based on the index of your layer, meaning two layers in different comps will have the same random if they have the same index. All layers inside a single comp, though, should be entirely random.

    Hope this is helpful!

    try{
    seedRandom(index, true);
    var randY = gaussRandom(0, 100);
    var randX = gaussRandom(0, 100);

    var key1Time = thisProperty.key(1).time;
    var key2Time = thisProperty.key(2).time;
    var key3Time = thisProperty.key(3).time;

    var key1Val = thisProperty.key(1).value;
    var key2Val = thisProperty.key(2).value + [randX, randY];
    var key3Val = thisProperty.key(3).value;

    if (time > key1Time && time < key2Time){ ease(time, key1Time, key2Time, key1Val, key2Val); } else if (time < key3Time) { ease(time, key2Time, key3Time, key2Val, key3Val); } else { value; } } catch(e){ value; }

    David Conklin
    Motion Designer

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