ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Trying to make random lines float across the screen.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ian Harper
Trying to make random lines float across the screen.
on Apr 8, 2019 at 5:04:42 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.


Return to posts index

Kalleheikki Kannisto
Re: Trying to make random lines float across the screen.
on Apr 9, 2019 at 10:03:32 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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]