Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Dan Ebberts’ Random Grid Movement with collision

  • Dan Ebberts’ Random Grid Movement with collision

    Posted by Jared Flynn on March 21, 2011 at 8:52 pm

    Hey folks,

    Possibly an easy one, or possibly a very tough one here. I’m working on a comp in which many light layers are moving on a 2D grid using Dan Ebberts’ Random Grid Movement technique. These lights will be driving Trapcode Particular emitters configured to essentially draw random straight lines around my comp.

    The trick: I would like to finagle this so that the lights NEVER cross over into a defined circular area in the middle of my comp. Ideally they would deflect off the boundaries of the circular area– not with any fancy momentum or anything, just change direction to divert away from the area– and continue making random position changes from there.

    The technique I’ve been trying to use to achieve this uses a precomped shape layer that represents my “no-fly zone,” along with the sampleImage() method to detect when a light is about to enter that area. Unfortunately I’ve been unable to figure out where and how to incorporate the sampleImage() method successfully; so far all my attempts just fail and disable the expression.

    If any of you chaps have an idea of how to do this, it’d be much appreciated!

    Jared Flynn
    Motion Graphics Designer / Lead AE
    Lone Wolf Documentary Group

    Jared Flynn replied 15 years, 1 month ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    March 21, 2011 at 11:49 pm

    Hmmm…. I can think of a couple ways to do it, but they both would require a fair amount of work. You could set up an array for the entire grid, with each array element containing the allowable directions for each corresponding node in the grid. For example, a node just to the left of your circle would only have the option to go up, down, or left.

    The other alternative would just be to do it with some math when selecting the next target. Just check to see if the next move could put you inside the circle, if so, eliminate that direction from the choices.

    A bit of work no matter how you approach it, I think.

    Dan

  • Jared Flynn

    March 22, 2011 at 2:09 pm

    Hi there Dan,

    Thanks for your thoughts! Both ideas seem like they’d do the trick… I will see what I can hack together. I am leaning toward your latter concept, of developing a check inside the next target selection. I bet that approach would save me some significant retooling on what’s already been done.

    Thanks again! I’ll try and post my result if I get it working.

    Jared Flynn
    Motion Graphics Designer / Lead AE
    Lone Wolf Documentary Group

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