Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Clamp expression on a child layer?

  • Clamp expression on a child layer?

    Posted by Tord-øystein Stubberud on May 30, 2018 at 2:05 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]

    Mamoun Odeh replied 7 years, 5 months ago 3 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    May 30, 2018 at 3:57 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

  • Tord-øystein Stubberud

    May 30, 2018 at 4:52 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!

  • Dan Ebberts

    May 30, 2018 at 5:39 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

  • Tord-øystein Stubberud

    May 30, 2018 at 6:33 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.

  • Tord-øystein Stubberud

    June 19, 2018 at 12:17 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])

  • Mamoun Odeh

    April 3, 2019 at 1:26 pm

    Hi Tord-Øystein!
    how i can move object in path move down and when touch path move up

  • Mamoun Odeh

    April 3, 2019 at 1:49 pm

    Hi !
    how i can move object .. up or right..etc when touch Path(curve ..not line) but i want down… ☹

    same https://www.youtube.com/watch?v=vQxD8OOjh-I .. 6:15
    please, i took myphoto you see and Thank.

    yP = thisComp.layer("Null 2").transform.position[1]
    clamp(yP, 0, -1500)

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

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