Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions axis/expression problem

  • axis/expression problem

    Posted by Pascal Greuter on February 13, 2007 at 2:37 pm

    Hi guys

    I have the following problem:

    I have two layers in a comp. When I move layer1 in the x axis, layer2 should be moved in the y axis and should get the same y value as layer 1. I tried the following expression on the position property of layer2:

    if (thisComp.layer(“layer1”).transform.position[0] == -102) {
    transform.position[1] == thisComp.layer(“layer1”).transform.position[1];
    }

    But this gets me an error message saying something like “Expression result must have dimension 2 not 1 (sorry, my AE is in german language).

    Can anyone give me a tipp?

    thanks

    Cheers, Pascal

    Lloyd Alvarez replied 19 years, 2 months ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    February 13, 2007 at 3:16 pm

    The way you have it set up, I would think you’d want it like this:

    if (thisComp.layer(“layer1”).transform.position[0] == -102) {
    [value[0], thisComp.layer(“layer1”).transform.position[1]];
    }else{
    value;
    }

    This leaves the layer in its position until layer1 has an x value of exactly -102, then it jumps to the same y value as layer1. Is that what you wanted?

    Dan

  • Pascal Greuter

    February 13, 2007 at 3:23 pm

    Hi Dan

    Yes, this is nearly what I was looking for. Many thanks!
    But it would be great when layer 2 moves to its new position instead of just jumping from the old to the new position. Can you also give me a hint on that?

    Thanks,
    Pascal

  • Pascal Greuter

    February 13, 2007 at 4:26 pm

    Hi Dan

    This is nearly the way it should work. Thank you very much. But is it also possible, to move layer2 to its new position instead of jumping?

    Thanks,
    Pascal

  • Dan Ebberts

    February 13, 2007 at 6:48 pm

    Possible, but not simple. I think you’d have to write some code that would start at the current comp time and loop backwards through the comp until you found the time when layer1 arrived a y = -102, then calculate where layer2 should be now based on how long it’s been, how fast you want the move to occur, and the distance to be traveled.

    Dan

  • Lloyd Alvarez

    February 13, 2007 at 7:12 pm

    depending on what direction you are traveling you could use linear:

    layer1position=thisComp.layer(“layer1”).transform.position;
    if (layer1position[0] <= -98 && layer1position[0] >= -102) {
    y=linear(layer1position[0],-102,-98,-102,value[1]);
    [value[0], y];
    }else{
    value;
    }

    -Lloyd

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