Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Trying to make random lines float across the screen.

  • Trying to make random lines float across the screen.

    Posted by Ian Harper on April 8, 2019 at 5:04 pm

    I have a comp where I am putting a dozen lines, that are all the same size and anchor point. I have made them 3d and I’m trying to write a script that will start them at different y and z coordinates, but they will move from off screen right to off screen left. As they are moving I don’t want their y and z values to change, I just want random start points. The x should be a pretty consistent speed.

    This is what I have so far, but I can’t figure out how to make the “y” and “z” keep the same random value from beginning to end. (I have left them in the ending value brackets just for display sake.)

    segMin = .3;
    segMax = .7;
    minVal = [4000, 0, -500];
    maxVal = [4000, thisComp.height, 500];
    minEndVal = [-2000, y, z]; //How do I get the generated numbers for the y and z to be returned to here?
    maxEndVal = [-2000, y, z]; //How do I get the generated numbers for the y and z to be returned to here?

    seedRandom(index,true);
    segDur = random(segMin, segMax);
    seed = Math.floor(time/segDur);
    segStart = seed*segDur;
    seedRandom(seed,true);
    startVal = random(minVal,maxVal);
    seedRandom(seed+1,true);
    endVal = random(minEndVal, maxEndVal);
    linear(time, segStart, segStart + segDur, startVal, endVal);

    Any help will be greatly appreciated.

    Kalleheikki Kannisto replied 7 years, 4 months ago 2 Members · 1 Reply
  • 1 Reply
  • Kalleheikki Kannisto

    April 9, 2019 at 10:03 am

    Move seedRandom(index, true) in the beginning of the expression and add the random y and z definitions before the minEndVal declaration line.

    Kalleheikki Kannisto
    Senior Graphic Designer

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