Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random lines expression crashes when i try to stop them

  • Random lines expression crashes when i try to stop them

    Posted by Max Huggett on February 3, 2010 at 2:59 am

    Hi Guys

    I have used Dans Random lines expression to animate a load of lines, travelling accross the screen. I want to be able to bring to a stop, the movement of the lines, at some point in time. So i have created a null and assigned slider controls – A minSeg and maxSeg. However when i keyframe this to 0, AE just hangs and will evenuaully crash as i have so many layers.

    The script i am applying is below.

    Also, i would like to bring these animated lines on from outside the boundaries of the comp, as they will be going over vision. At present, i am positioning them off frame at Time 0sec. Is this the correct way to do this or does the expression need to be adapted.

    Thanks alot


    beginTime = thisComp.layer("Control").effect("Begin at")("Slider");

    if (time<=beginTime) {
    value
    }else {
    t = time - beginTime;
    tMin = thisComp.layer("Control").effect("Min Seg")("Slider"); //minimum segment duration
    tMax = thisComp.layer("Control").effect("Max Seg")("Slider"); //maximum segment duration

    end = 0;
    j = 0;
    while (t >= end){
    j++;
    seedRandom(j,true);
    start = end;
    end += random(tMin,tMax);
    }
    endVal = random(thisComp.width);
    seedRandom(j - 1,true);
    x = random(); //this is a throw-away value
    if (j > 1){
    startVal = random()*this_comp.width;
    }else{
    startVal = value[0];
    }
    x = ease(t,start,end,startVal,endVal);
    [x,value[1]]
    }

    Max Huggett replied 16 years, 3 months ago 2 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    February 3, 2010 at 4:01 am

    Yeah, if you set those durations to zero you’ll create an infinite loop.

    Have you considered just using a horizontal wiggle, and tying the amplitde to a slider control which you would keyframe to zero. It probably wouldn’t be too tough to get them to slide in from off screen too. Is there a particular arrangement you want them to end up in?

    Dan

  • Max Huggett

    February 3, 2010 at 4:57 am

    Hi Dan.

    Not particulary. My client is just after random motion. Your wiggle idea sounds fine. I will give that a try.

    Thanks

  • Max Huggett

    February 3, 2010 at 4:59 am

    Can a wiggle be confined to the comp space, even if i am starting the shapes outside of the frame?

  • Max Huggett

    February 3, 2010 at 5:51 am

    Can anyone help me with this script please?

    My aim is to have many vertical lines, of different widths, moving randomly sideways within the confinds of the comp.

    This script, goes top to bottom and i would like this to go sideways, but don’t know how to change the script. Any help would be greatly appreciated.

    Thanks alot

    seedRandom(index, 1)
    r =random(0, 100);
    freq = random(.1, .3);
    n = wiggle(freq, 100 + r);

    [thisComp.width, n[1]]

  • Dan Ebberts

    February 3, 2010 at 5:57 am

    Here’s an example for a layer that starts 50 px offscreen to the left, at 1 second in it slides into the comp-width wiggle:

    timeToStart = 1;
    transitionTime = .5;
    startX = -50;
    xAmplitude = thisComp.width/2;
    w = wiggle(1,xAmplitude);

    x = ease(time,timeToStart,timeToStart+transitionTime,startX,w[0]);
    [x,value[1]]

    I’m guessing that with a little tweaking, this could work for you.

    Dan

  • Max Huggett

    February 3, 2010 at 6:07 am

    Dan thats brilliant. Thank you so much. Just one question though. What part of your code, do i attach to the expression slider to keyframe it.

    Thanks so much.

  • Max Huggett

    February 3, 2010 at 6:23 am

    Sorry Dan…. I got it working just the way i wanted. Thanks so much for your help on this.

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