Pseudo object 'awareness' expression

Moderators: Disciple, zlovatt

Post Reply
fiveshorts
Posts: 5
Joined: July 10th, 2007, 10:48 am

Hi.

So, I have three, rectangular shape layer objects in my composition.
All are moving L to R across the comp over time, like three wooden blocks being pushed across a table: object 1 appears to be pushing 2 , which in turn appears to be pushing 3.
Making object 1 a sort of parent to 2 etc.

All easy until I want to change the x width of object 1.
As I reduce it's width over time to, say, 50%, I need object 2 to remain butted up to 1's rightmost edge, and 3 to 2’s.

It seemed simple at first, and I did fudge it temporarily by precomposing the L-R move of each object and then key framing time remapping. But my eyes started to bleed trying to manage all the variables.

At any time, any of the objects might need to have it's width changed WHILST IN MOTION without losing the relationship to the object they are 'pushing'.

To labor the point, here's an example:

Five rectangular shape objects arranged sequentially left to right in a comp.
Moving # 1 to the right "pushes" 2 thru 5 to the right.
As that move occurs, #3 scales in the X dimension by 50%
it still needs to "push" 4 & 5 as it scales.



I'm not a mathematician. Would someone be kind enough to point me towards a syntax that might make this less painful?

Many thanks in advance.
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

Try this with all the layers but the left-most. It assumes the left-to-right order of the layers corresponds to a top-to-bottom order in the layer stack. If the left-most layer isn't Layer 1, you'll need to edit the first line. Also, it won't work right if the anchor points aren't centered on x.

Code: Select all

firstIdx = 1; // index of left-most layer in chain
offset = 0;
for (i = firstIdx; i < index; i++){
  L = thisComp.layer(i);
  if (i == firstIdx)
    offset += L.width*L.transform.scale[0]/200
  else
    offset += L.width*L.transform.scale[0]/100;
}
x = thisComp.layer(firstIdx).transform.position[0] + offset + width*transform.scale[0]/200;
[x,value[1]]

Dan
fiveshorts
Posts: 5
Joined: July 10th, 2007, 10:48 am

As always Dan, thank you. Don't know how you do it.
As soon as I get to my primary machine tomorrow I will try this out and report back.

Thank you.
Post Reply