Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random X,Y Array for Lightning Source Points

  • Random X,Y Array for Lightning Source Points

    Posted by Joe Jozwowski on February 7, 2012 at 9:12 pm

    Ok Cow Gurus,

    I have a concept that may make blood shoot out your nose.

    I’m looking to create an array of pre-set X,Y coordinates (say 5-6 entries) that I would like a the built-in lightning effect to use as start and end points.

    But I would like the start and end points to randomly change from one set to the next.

    I wouldn’t care if each change would happen at a regular interval, I just want the start and end points to be different each time the expression is fired.

    – If you were me, you’d be home by now!
    Joe Jozwowski
    The Video Alchemist

    Dan Ebberts replied 14 years, 3 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    February 7, 2012 at 9:33 pm

    You’ll need separate expressions for start and end, but this is the basic idea:

    points = [[100,100],[200,100],[300,100],[400,100],[500,100]];
    idx = Math.floor(random(points.length));
    points[idx]

    It gets slightly more complicated if you decide you don’t really want it to change every frame, or if you want a particular start point to always go with a particular end point.

    Dan

  • Joe Jozwowski

    February 7, 2012 at 9:48 pm

    How much more complicated?

    Right now I have 6 shape layers that are on a constant wiggle so their X-Y coordinates fluctuate throughout.

    Where you have points = [[100,100],[200,100], etc]…

    Could I just use the X-Y coordinates of those shape layers, e.g.

    points = [[thisComp.layer(“Shape Layer 6”).transform.position[0],thisComp.layer(“Shape Layer 6”).transform.position[1]],[thisComp.layer(“Shape Layer 5”).transform.position[0],thisComp.layer(“Shape Layer 5”).transform.position[1]], etc.]

    If perchance that the Start and End points are the same, that I’m not worried about…

    – If you were me, you’d be home by now!
    Joe Jozwowski
    The Video Alchemist

  • Joe Jozwowski

    February 7, 2012 at 9:56 pm

    Dan,

    I just saw another post you commented on a while back dealing with a similar issue, and you suggested to add a seedRandom(index,true) into the mix.

    With that, I can just add a Slider control, with a Hold Keyframe every second and increment that “index” by whatever I want, and that would change the seedRandom value when I specify, correct?

    – If you were me, you’d be home by now!
    Joe Jozwowski
    The Video Alchemist

  • Dan Ebberts

    February 8, 2012 at 12:43 am

    I would calculate the seed based on which time interval you’re in. Here’s an example that would calculate a new seed every half second (not tested, but should be close).

    segDur = .5;
    t = time – inPoint;
    seed = Math.floor(t/segDur);
    seedRandom(seed,true);

    Dan

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