Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions random movement within a shape of a shapelayer

  • random movement within a shape of a shapelayer

    Posted by Baba Luba on May 2, 2019 at 11:32 pm

    Hi!

    I want to move some small icons within the boundaries of a ShapeLayer a rectangular shape will do.
    I want so move and scale this shape, so the parts within move with it.
    Not from border to border, more like a wiggle random movment, but in a specific area. It would be cool to also control the “wiggle” parameters (speed and how far before direction change – easing would be cool too).

    i found this: https://www.aecheatsheet.com/quick-tutorials/bounding-box-with-clamp

    but the movement is too fast and not really controlable

    any ideas?
    thanks in advance!

    Filip Vandueren replied 7 years ago 2 Members · 1 Reply
  • 1 Reply
  • Filip Vandueren

    May 3, 2019 at 5:30 pm

    Maybe something like this expression.
    It uses noise() to produce wiggle-like values, and then maps these within the shape, including scale, position, and rotation.
    Mind: the contained layers ar wiggling and spread out according to avaliable space, almost as if parented to the shape.
    It doesn’t “push” against the particles when the “cage” moves, nor do they bounce off the wall, etc…

    If you need that behaviour, it would be more like programming a particle system which expressions are capable of, but very slow at.

    wiggleSpeed=1;
    margin = 25;

    l = thisComp.layer("Shape Layer 1");
    sr = l.sourceRectAtTime();

    seedRandom(index,true);
    randomX = linear(noise(wiggleSpeed*time+random(999999)), -1,1,sr.left+margin, sr.left+sr.width-margin);
    randomY = linear(noise(wiggleSpeed*time+random(999999)), -1,1,sr.top+margin, sr.top+sr.height-margin);

    l.toComp([randomX,randomY]);

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