Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Offsetting position coordinates

  • Offsetting position coordinates

    Posted by Rob Nairn on March 13, 2008 at 5:32 am

    Hi there,
    I’m a newbie to expressions and have been working on this one all day. I’ve been reading some the posts and tutorials so you might notice some replicated code (thanks to those who have put up code I’ve copied!) But now my brain has turned to mush, so I need some help…

    What I am simply trying to do is to take only one part of a position coordinate (say the x value) from one layer and have that duplicated in the layer below. With the code I am using it tells me the expression can’t be more than one value.

    In more detail i am trying to get duplicated layers to follow behind the the main layer by offsetting the time at which it duplicates the position coordinates. Thats been all good:
    i = index – 1;
    thisComp.layer(i).transform.position.valueAtTime(time-.5);

    But now I want to offset the x, y, z values independently. So that the x value is say .5 sec behind, the y value is 1 sec and z value is 1.5 behind. I’ve tried using the above code for each value like this:

    i = index – 1;
    x = thisComp.layer(i).transform.position.valueAtTime(time-.5);
    y = thisComp.layer(i).transform.position.valueAtTime(time-1);
    z= thisComp.layer(i).transform.position.valueAtTime(time-1.5);
    [x,y,z]

    This is where it tells me it can’t expand to more than one value. I can see that it’s trying to copy in the whole coordinate for each value but I can’t work out how to alter the code to insert only the corresponding value.

    Hope that makes some sense – I’m too wrapped up in it to make top or tail of it for the moment.

    Thanks Rob

    Rob Nairn replied 18 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    March 13, 2008 at 1:08 pm

    Try it like this:

    i = index – 1;
    x = thisComp.layer(i).transform.position.valueAtTime(time-.5)[0];
    y = thisComp.layer(i).transform.position.valueAtTime(time-1)[1];
    z= thisComp.layer(i).transform.position.valueAtTime(time-1.5)[2];
    [x,y,z]

    Dan

  • Rob Nairn

    March 13, 2008 at 10:19 pm

    Hi Dan,
    That has worked a treat. I saw a thread that referenced your wiggle in only one direction exercise, but by that stage I’d drunk too much coffee to see the parallels. Thanks for the help. Much appreciated,
    Rob

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