timeOffset

Moderators: Disciple, zlovatt

Post Reply
Tom
Posts: 5
Joined: August 30th, 2007, 8:23 pm
Location: Chandler, AZ USA
Contact:

Trying to understand the use of the timeOffset command. Specifically, as it is used in the Photo Flow effect posted by Paul Tuersley. How does this expression effect the x and y positions. My goal: gain enough understanding so I could modify it to effect the z My understanding of Java script is halting and vague at best, but with enough research, many times I am able to figure out most of the shorter expressions. This one is tough. Help Please, if you have the time.


here is the code:


timeOffset = thisComp.layer("control layer").effect("Slider Control")("Slider") / 10;
thisComp.layer("control layer").transform.position.valueAtTime(timeOffset +
(index * thisComp.frameDuration * 50));


Thanks,
Tom Ronai
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

What you're really asking is how to use the "valueAtTime" command. TimeOffset is just the name of a variable I'm using in the expression.

In the PhotoFlow project there's a layer called "control layer" which contains the keyframed animation for the photoflow effect. All the other layers are using the animation from that layer, but slightly offset in time.

If you applied this expression to the position property of another layer, the result would be that the layer exactly matched the control layer's position animation:

Code: Select all

positionProp = thisComp.layer("control layer").transform.position;
positionProp.valueAtTime(time);
If you used this expression it would do the same animation, but 1 second later.

Code: Select all

positionProp = thisComp.layer("control layer").transform.position;
positionProp.valueAtTime(time - 1);
If you use index instead (which gives you the number of the layer as stacked in the Timeline), then keep duplicating the layer, each subsequent layer will be offset in time by one second more.

Code: Select all

positionProp = thisComp.layer("control layer").transform.position;
positionProp.valueAtTime(time - index);
As you probably don't want to stagger the animation by exactly 1 second, you may need to feed another value into the expression as a multiplier for the offset:

Code: Select all

positionProp = thisComp.layer("control layer").transform.position;
multiplier = thisComp.layer("control layer").effect("Slider Control")("Slider");
positionProp.valueAtTime(time - (index * multiplier));
To be honest, that expression in the Photo Flow project isn't the nicest I've ever written. I'm a little puzzled exactly what I was thinking when I wrote it myself.

Paul
Tom
Posts: 5
Joined: August 30th, 2007, 8:23 pm
Location: Chandler, AZ USA
Contact:

Got it. So the control layer is animated with key frames, and the "valueAtTime" expression determines when the visible photo layer will play. The variables are provided by the slider. So, if I wanted the layers to move forward in z space I only have to change the control layer animation. Next question: Why does the "control layer" when placed at the top become the controlling layer? Why do you not get some kind of error message about which control layer you are referring to?

Thanks for your valuable time,
Tom Ronai
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

If an expression refers to a layer by name, and there is more than one layer with that name, the expression uses the highest of those layers in the timeline. I just took advantage of that behaviour so I could try out different animations.

Paul
Tom
Posts: 5
Joined: August 30th, 2007, 8:23 pm
Location: Chandler, AZ USA
Contact:

Suspicions confirmed.

Thanks again,
Tom Ronai
Post Reply