Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression for random rotation with angle limit

  • Expression for random rotation with angle limit

    Posted by Ísis Daou on December 17, 2012 at 11:14 pm

    Hey guys,

    I’m developping now my very first animation on After Effects and I would like to use expressions to add some random and smooth movement on my character.

    This is the character:

    What I wanna do is move some of these hair curls (each of them is an independent layer, of course) with a slight random rotation, but I need to have control on the amplitude of the rotation – some of these curls may rotate only 20 degrees, other can be less or more, i need to adjust these value for each one of them.

    I’m using now this following code found here and the random movement seems great, but it’s way too fast and I have no idea how to put a value to control the amplitude of the rotation (I tried “amplitude = 30;” at the beginning and the end, but I didn’t work).

    If someone knows how to help I’d very thankful 🙂

    j = 0; //initialize loop counter
    accum = 0; //initialize random accumulator
    seedRandom(index,true)

    while (j < time){
    accum += random(10);
    j += thisComp.frameDuration;
    }

    rotation + accum

    Ísis Daou replied 13 years, 7 months ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    December 17, 2012 at 11:41 pm

    Have you thought of using wiggle() for this?

    Dan

  • Bryan Woods

    December 18, 2012 at 6:54 am

    Yup, what Dan said. I’d use the wiggle expression with a slider on a null object.

    Create a null object, then add the effect “expression slider”.
    Then go to the rotation property and put in this expression:
    wiggle(1,slider);

    The first value of wiggle is the frequency. 1 would mean “do this every 1 second”. The second value is the amplitude. Usually, you’d put a number in here, but if you want to be able to keyframe your wiggle, then you should pickwhip that null you created with the slider control for this value instead. Now you can keyframe the slider. 0 = no wiggle.

    So, assuming your null is unnamed, your expression would look something like:
    wiggle(1,thisComp.layer("Null 1").effect("Slider Control")("Slider"));

    Adjust the first value to speed up or slow down the frequency of your wiggle and this should get you the result you’re looking for.

  • Ísis Daou Create COW Profile Image

    Ísis Daou

    December 18, 2012 at 2:42 pm

    wow, this works REALLY fine. thank you a lot!

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