Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Move object ONLY along path y axis

  • Move object ONLY along path y axis

    Posted by Julien Stoll on March 14, 2021 at 3:30 pm

    I have a mouse cursor moving over time across x & y and an object attached to it. The object now moves simultaneously with the cursor over time. So far so good.

    I now need the attached object to follow the path of a curve.

    Essentially the object needs the y-axis data precisely at the same in time as the mouse cursor is moving along the x-axis …

    So far I’m failing at doing that … the mouse cursor movements have been drawn with motion sketch. Is an expression needed to achieve this?

    Walter Soyka replied 5 years, 5 months ago 3 Members · 5 Replies
  • 5 Replies
  • Julien Stoll

    March 15, 2021 at 8:11 pm

    Sorry, I need to rephrase my question … too hard to understand currently.

    What I wanted to say:

    I have a bar moving from left to right. I now need a dot to follow the bars movement on the x-axis. Therefore I parent the dots x-position the bars x-position. However I now also need the dot to follow the path of the curve while it’s parented to the bar. Essentially the missing data for the dot is the y-position of the curve path at time x of the bar.
    As you can see the in the example renders either the dot and bar are out of sync or the dot is not following the path properly … How to fix this?

  • Kevin Camp

    March 16, 2021 at 8:53 pm

    You can take the the x-value from one object and combine it with the y-value of another using expressions…

    In your first example where the dot’s position is following the curve, I’ll assume that it is using the keyframes, which will make it a little easier, so start with that one.

    Right-click the position property for the dot layer and choose Edit Expression to add an expression to that property.

    Then add this expression to the expression field:

    target = thisComp.layer("My Line") ;  //change "My Line" to your line layer's name
    x = target.postion[0] ;
    y = position[1] ;
    [ x, y ]

    Make sure to change the “My Line” to the name of your layer, keeping the quotes.

    What it should do is take the y-value from the target layer (your line) but keep the current x-value of the current layer (the dot).

  • Julien Stoll

    March 16, 2021 at 9:15 pm

    Thanks for your reply! Unfortunately the expression doesn’t work for me … The expression you have written only pulls the x-position of the target layer, doesn’t it? .. I corrected it to pull the y-position and also corrected the typo. The dot now seems to follow the shape of the curve however there is now a weird offset …

  • Kevin Camp

    March 16, 2021 at 10:02 pm

    Sorry Jules, this method won’t work here… it worked on a simple set up I made, but testing it with a more organic line it will not work.

    And sorry for the typo.

    I think you’d need to do the animation and the wave path with sin or cos calculations.

  • Walter Soyka

    March 17, 2021 at 6:45 pm

    This is a problem that seems like it should be easy, but it’s actually quite difficult to do automatically/procedurally with expressions for an arbitrary shape.

    I think the fastest solve is probably to use an expression to position your follower object along the path. This will be expressed as a percentage, where 0 is the first point on the path and 100 is the last. Then you can pretty quickly animate that completion to match the bar’s position by hand.

    See attached sample project for a reference and let me know if you have any questions.

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