Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Wiggle in one dimension with a floor

  • Wiggle in one dimension with a floor

    Posted by Riccardo Sinti on June 5, 2013 at 4:15 pm

    I’ve seen many posts on this problem but just cant seem to get how to do it or the get results I need form some of the expressions that have been posted.
    Im using this expression on a 3d layer to wiggle only in the Y dimension.

    w = wiggle(6,250);
    [value[0],w[1],value[2]]

    I would like to create a floor for the wiggle so my layer doesn’t go below the floor.

    I understand the clamp expression should be used but I am not sure how to add it to this expression.

    Any help would be appreciated.

    Thanks!

    Riccardo Sinti replied 12 years, 11 months ago 3 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    June 5, 2013 at 5:12 pm

    Maybe something like this:

    minY = 100;
    w = wiggle(6,250);
    [value[0],Math.max(w[1],minY),value[2]]

    Dan

  • Xavier Gomez

    June 5, 2013 at 5:18 pm

    To clamp below, you can use:

    floor = 0;
    y = Math.max( wiggle(6,250)[1], floor);
    [value[0],y,value[2]]

    Clamping a wiggle doenst work very well because while out of the bounds the final value (y-coordinate) will be constant.

    Provided yours key values always stay above the floor, you can use instead:

    floor = 0;
    maxWiggle = Math.min(250, value[1]-floor);
    w = wiggle(6,maxWiggle);
    [value[0],w[1],value[2]]

    Xavier

  • Riccardo Sinti

    June 6, 2013 at 5:09 pm

    Thanks guys for your help but none of those seem to do what I wanted.

    I wound up using this which I cobbled from a the same question I realized I posted many years ago

    w = wiggle(4,200) – value;
    value + [value[0],-Math.abs(w[1])]

    It kept my wiggle in the Y axis from dropping below the layer’s original y start point but when I apply it the layer’s x shifts so I have to relocate along the x axis. I guess that is from adding value + before the [value[0],
    z is not affected I guess because it isn’t mentioned in the array?

    Any idea how to rewrite this so I can leave x and z dimensions alone.

    The next thing I would like to do is be able to add an expression to scale so that when I scale the layer it’s lower edge will always touch the floor.

  • Dan Ebberts

    June 6, 2013 at 6:55 pm

    This should work:

    w = -Math.abs((wiggle(4,200) – value)[1]);
    value + [0,w,0]

    For the scale, couldn’t you just move the Anchor Point to the middle of the bottom edge?

    Dan

  • Dan Ebberts

    June 6, 2013 at 6:59 pm

    I may have misunderstood the second part. So you want to wiggle the layer in the y direction and scale it at the same time so that the bottom edge doesn’t move, is that correct?

  • Riccardo Sinti

    June 7, 2013 at 3:02 pm

    That last expression works great and I actually understand how it is working.

    “you want to wiggle the layer in the y direction and scale it at the same time so that the bottom edge doesn’t move,”

    That’s right, I want the bottom edge to stay at floor level.

    I don’t want to move the anchor point because it rotates around center.

    Thanks for all the help you give this community!

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