ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Clamp expression on a child layer?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Tord-Øystein Stubberud
Clamp expression on a child layer?
on May 30, 2018 at 2:05:15 pm

Hi, I'm fairly green when it comes to understanding expressions, and I have a small problem with the clamp expression. I have NULL that I want to restrict from passing through a "floor". So i add the clamp expression to its position and everything works, it stops where I need it to stop. The problem comes when I have to link this same NULL to a different parent NULL which also has animation on it. When I link these two together, the expression on the child NULL somehow stops working (no error message), and it can pass through the floor again.

Can someone help me out?

yClamp=clamp(transform.position[1],-800,800);
[transform.position[0],yClamp]


Return to posts index

Dan Ebberts
Re: Clamp expression on a child layer?
on May 30, 2018 at 3:57:08 pm

I haven't tested it, but give this a try:

p = toComp(anchorPoint);
yClamp=clamp(p[1],-800,800);
fromComp([p[0],yClamp])


Dan



Return to posts index

Tord-Øystein Stubberud
Re: Clamp expression on a child layer?
on May 30, 2018 at 4:52:39 pm

Thanks for replying! : ) but no, that didnt quite work. I place this expression in the child layers position, correct? It kinda flips out a bit : P
Thanks again!


Return to posts index


Dan Ebberts
Re: Clamp expression on a child layer?
on May 30, 2018 at 5:39:17 pm

That's what I get for not testing it. Try it this way:

p = toComp(anchorPoint);
yClamp=clamp(p[1],-800,800);
parent.fromComp([p[0],yClamp])


Dan



Return to posts index

Tord-Øystein Stubberud
Re: Clamp expression on a child layer?
on May 30, 2018 at 6:33:12 pm

Thank you! I have no idea how it works, but been looking for a way to get this working for a long time : D Amazing.


Return to posts index

Tord-Øystein Stubberud
Re: Clamp expression on a child layer?
on Jun 19, 2018 at 12:17:54 pm

Hi again! I now had a chance to try this expression out on a project, and although it works perfectly for what I described earlier, I now see that I forgot to add an important detail earlier. The child layers (in this case NULLs) also has to ignore the rotation of the parent layer. Right now, when I rotate the Parent, the child layers rotate around the parents anchor point. Is there a way to ignore the positional displacement that comes from rotating the parent layer? (I hope im making sense here...) Anyway THANKS!

p = toComp(anchorPoint);
yClamp=clamp(p[1],0,890);
parent.fromComp([p[0],yClamp])


Return to posts index

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