Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Link only x position to Rotation

  • Link only x position to Rotation

    Posted by Salvatore Chiarenza on September 18, 2015 at 10:32 am

    Hi everybody! I’ll explain my problem.

    I have two layers: a GEAR and a TEXTBOX. Basically i want to link the rotation of the GEAR to the X position of the textbox so that when i animate the rotation the TEXTBOX slides horizontally.
    I know that it must be a pretty simple expression but how can i tell to AE to only change the X value?

    Thanks for helping!

    Xavier Gomez replied 10 years, 11 months ago 2 Members · 3 Replies
  • 3 Replies
  • Xavier Gomez

    September 18, 2015 at 2:11 pm

    I think that this should work:

    pos = value;
    r = thisComp.layer(“GEAR”).transform.rotation;
    pos[0] += (time-inPoint)*(r.value-r.valueAtTime(inPoint));
    pos;

    Xavier.

  • Salvatore Chiarenza

    September 18, 2015 at 2:20 pm

    Thanks i’ll try it out and tell the result. Can you please explain the meaning of each line? I’d like to understand what i am doing 🙂

  • Xavier Gomez

    September 18, 2015 at 6:05 pm

    Good that you ask, i realize that it was sort of wrong. It should be more like this:

    a = 100/360;
    pos = value;
    r = thisComp.layer(“GEAR”).transform.rotation;
    pos[0] += a *(r.value-r.valueAtTime(inPoint));
    pos;

    it adds something that is proportionnal to the rotation variation to the x component (component 0) of the position. For a = 100/360 it will add 100 pixel for one complete turn, etc.

    The first 3 lines simply define some variable to be used.
    pos stores the current value (before expression).
    The the variation is added to the component 0.
    To calculate a variation, one needs a reference value, i assumed that the reference should determined at the layer’s inPoint, but you might need something else.
    Then the last line, just ‘pos’, tells what is the final result to be retained.

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