Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to wiggle only in multiples of a set number

  • How to wiggle only in multiples of a set number

    Posted by Nick Matthews on February 17, 2015 at 11:15 pm

    Say I have a grid, with a shape layer ‘filling’ one of the grid squares (exact same size as one square).

    I would like to wiggle along the Y-axis that only adjusts position in chunks equal to the size of the grid squares.

    So if my wiggle was 3 times/sec, each of those position adjustments would happen in multiples of the size of the grid squares, such that the shape layer would always fit snugly in each empty square.

    How would I go about writing this?

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

    February 18, 2015 at 12:34 am

    Something like this maybe:

    gridSize = 100;
    freq = 3;
    wiggleAmt = 500;
    wy = (wiggle(freq,wiggleAmt)-value)[1];
    dy = Math.floor(wy/gridSize)*gridSize;
    value + [0,dy]

    Dan

  • Nick Matthews

    February 18, 2015 at 1:53 am

    Awesome job. This works perfectly, thanks!

    If you don’t mind explaining things further to someone with a rudimentary understanding of coding, how are the bottom lines calculating? It looks like ‘dy’ is dividing ‘wy’ with gridSize and then multiplying the same value (gridSize) again.

  • Dan Ebberts

    February 18, 2015 at 3:28 am

    The last part just divides the y wiggle amount by the grid size, rounds that down to get a whole number of grid units and then multiplies by grid size to get it back to pixels, but on a grid boundary.

    Dan

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