ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Enable Clamp Expression on a linked value?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Michael Müller
Enable Clamp Expression on a linked value?
on Feb 8, 2018 at 3:10:55 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)


Return to posts index

Dan Ebberts
Re: Enable Clamp Expression on a linked value?
on Feb 8, 2018 at 5:18:09 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



Return to posts index

Michael Müller
Re: Enable Clamp Expression on a linked value?
on Feb 8, 2018 at 7:34:17 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.


Return to posts index


Dan Ebberts
Re: Enable Clamp Expression on a linked value?
on Feb 8, 2018 at 7:38:45 pm

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

Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]