Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random positions

  • Posted by Sanniti Towiwat on March 16, 2018 at 9:58 am

    Hello everyone

    This is my first question here.

    I have a composition with many layers about 50+ layers each one is animated

    I want them to pop out in random position so I used this expression for each one;

    seedRandom(index, true);
    x = random(0, thisComp.width);
    y = random(0, thisComp.height);
    [x, y]

    but some of layers are overlap and out of comp space.

    I want them being separate and not overlap each other and still in comp space.

    This is my current result here:
    comp1.png

    Thank you.

    Kevin Camp replied 8 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • Kevin Camp

    March 19, 2018 at 5:29 pm

    you need the expression to account for layer height and width when calculating the boundaries for the random position area.

    if the anchor points are in the centers of each layer, this should deep them within the boundaries of the comp:
    seedRandom( index, true ) ;
    xSize = width * scale[0] / 100 ;
    ySize = height * scale[1] / 100 ;
    x = random( xSize / 2, thisComp.width - xSize / 2 ) ;
    y = random( ySize / 2, thisComp.height - ySize / 2 ) ;
    [x, y]

    I don’t know of a good way to prevent overlapping layers with a random expression…. you could work a way to manually adjust the position for overlapping layers… so the expression would do 75% of the work, but you’d need to adjust several of the layers that overlap….

    to try that, set the layers’ positions to 0, 0 and change the last line to:
    value + [ x, y ]
    you should now be able to move overlapping layers manually.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

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