Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Enable Clamp Expression on a linked value?

  • Enable Clamp Expression on a linked value?

    Posted by Michael Müller on February 8, 2018 at 3:10 pm

    Hello community,

    I’ve got the following problem (added an image to make it more clear):
    pong.png

    As the ball moves, it’s position in the comp is tracked by a null with the toComp expression on its position value.
    I want the red paddle on the left to follow the ball’s Y Position, so I pickwhipped it.
    I also want the paddle to stop at a certain value, so it doesn´t go outside the comp in case the ball reaches the top.
    The paddle currently is connected to a null.
    On that nulls Y Position I’ve added

    thisComp.layer(“BallTrack”).transform.position[1];

    to track the movement. As soon as I add a clamp expression (for example clamp(transform.yPosition,-225,600)) the value is stuck at (in this case) 600.
    I’ve tried several things like putting it before or inbetween, nothing seems to work.

    I’m pretty much at a beginner level and this is my first post on the forum, please go easy on me.

    Thanks a lot

    -Michael

    thisComp.layer("BallTrack").transform.position[1];
    clamp(transform.yPosition,-225,600)

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

    February 8, 2018 at 5:18 pm

    You want to clamp the result of the first line, is that correct? You could do it like this:

    y = thisComp.layer(“BallTrack”).transform.position[1];
    clamp(y,-225,600)

    Dan

  • Michael Müller

    February 8, 2018 at 7:34 pm

    Thanks Dan, that was just what I needed!

    Probably I should get into the habit of creating variables instead of pickwhipping, I wasn’t aware of the fact that this could mess up an expression.

  • Dan Ebberts

    February 8, 2018 at 7:38 pm

    Yeah, without the variable, the result of the first line gets discarded.

    Dan

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