Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Defining limits for rotation expression

  • Defining limits for rotation expression

    Posted by Christopher Sean on November 7, 2013 at 12:43 pm

    Hi everbody!

    Usually I’m not the one to post questions about basics, because pretty much anything is already documented, but this time I am missing the forest for the trees.

    Ok so this is what I’m failing to accomplish: A layer that is rotated from 0° to a random number of degrees between -25° to 25° in 4 frames.

    I suppose the logic would be to set a rotation from a to b and define b as a random number, but I’m not sure where to start.

    I would really appreciate any help! Thanks!

    Christopher Sean replied 12 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Kevin Camp

    November 7, 2013 at 6:52 pm

    [Christopher Sean] “I suppose the logic would be to set a rotation from a to b and define b as a random number”

    Yep, that’s what you want to do. Here’s one way to do it:
    seedRandom(index,true);
    r = random(-25,25);
    if (numKeys == 2)
    linear(time-key(1).time,0,key(2).time,key(1).value,r);
    else
    value;

    you hadn’t mentioned timing, so i set it up to use to keyframes to allow you to define the timing with keys (which is typically how i’d do it anyway).

    so the expression looks for keyframes, you need two to define the start point and the end point. the expression will use the value of the first keyframe as the start value, so set that to zero, the value of the second keyframe does not matter, since it will be replaced by the random value, it only uses it’s placement for timing.

    the linear() function just interpolates the time between the two keyframes to the rotation values. if you wanted to ease between the keyframes, you can change linear() to ease() — note changing the keyframe interpolation will not effect the animation, since the interpolation of the expression will override that of the keyframes.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Christopher Sean

    November 19, 2013 at 10:20 am

    Thank you very much! This really helped me out.

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