Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Index position isn’t working between comps and shapes

  • Index position isn’t working between comps and shapes

    Posted by Thomas Hannen on March 13, 2023 at 9:49 am

    I have many shapes that I want to reference to a single comp with a shape in it, in case I need to change them later on.

    The shapes are 2D and in different positions all over my canvas.

    I want to be able to position each comp using the position data from the layer above it.

    When I try to map the position data from the layer above, I get the wrong position.

    What am I doing wrong?

    As a simple example – I want to position the green star in the same place at the pentagon. The pentagon is pre-comped in a 300×300 comp, but everything is centred.

    I put this in the star’s position field:

    x = (index-1);

    y = (index-1);

    [x,y]

    And place the star layer below the pentagon layer.

    Why does the star jump to -1,-1?

    Thomas Hannen replied 11 months, 2 weeks ago 1 Member · 1 Reply
  • 1 Reply
  • Thomas Hannen

    March 13, 2023 at 10:46 am

    ah I think i’ve got it:

    x = thisComp.layer(index-1).position[0];
    y = thisComp.layer(index-1).position[1];
    [x,y]
    

    (I was returning the value of the layer, not the position of that layer)

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