Expressions/Scripts/Presets

 
User avatar
Disciple
Topic Author
Posts: 137
Joined: Sat Jun 05, 2004 8:05 am
Location: Los Angeles, CA
Contact:

Offset position for mutliple keyframes

Thu Sep 09, 2004 7:06 am

This tutorial will help you with a very simple task, but that, in my experience, can occur quite often.

When you have a layer with many keyframes applied to it, may it be by you, by the tracker, by the wiggler, by expressions converted to keyframes, by motion sketching, or any other technique, you may feel that even though everything is looking good, there is a slight offset in position, scale, opacity or rotation that would make your animation look much better.
Problem is, having so many keyframes, it would be a hassle to go into the timeline and edit each one individually.

Here is a concrete example : I tracked a stick, that a character is holding. There is some movement in the stick, as if the flag holder was in a windy location. There was no flag in the shot, so I created a solid that I tracked to the stick.
Once the keyframes where applied, I realized the flag was slightly offset from the flag, perhaps because my attach point wasn't perfectly placed.
At any rate I needed to offset the positon for ALL my keyframes.


Image
Image

I found that I could offset position on the X axis using this expression on the "position" stream:
position +15

But I also wanted to offset the Y axis, at this point I needed some help from Paul Tuersley. He explained that "position" is an example of an array, which just means something that stores more than one value (position has an X value and a Y value).

This is how arrays are written in expressions:
[10, 20]
That expression would set a layer's position to 10 on the X axis and 20 on the Y axis.

To add two arrays together, you would write an expression like:
[10,20] + [15, -2]
So that's 10 + 15 and 20 - 2, which results in [25, 18].... setting the layer's position as 25 on X and 18 on Y.

In the expression language the word "position" represents an array that you could think of as [current X position, current Y position] so the expression I needed for my offset is really just another example of adding two arrays together:
position + [15,-2]
With the result being that all my position keyframes have been offset by +15 on the X axis and -2 on the Y axis.

Paul also pointed out that although my original expression (that just offset the X axis) position + 15 worked, I should really get used to writing it as:
position + [15,0]


You can use this technique for offsetting pretty much any parameter in After Effects. Just remember that for things like anchor point, position or scale which have 2 (x,y) or 3 (x,y,z) values, you are dealing with arrays and need to use this method:
anchorPoint + [-23, 40]
scale + [0, 0, 100]


Whereas, if the parameter only has one value, such as opacity or rotation, you can just use:
opacity - 20
rotation + 90



---------

A little note : AE is a powerful app that often gives you more than one way to solve problems. In this case I could have parented my layer to a null, then used that null to offset the original layer's position.
 
cressa
Posts: 2
Joined: Mon Apr 06, 2009 11:00 am

Re: Offset position for mutliple keyframes

Fri Apr 17, 2009 12:41 pm

is there a way to offset the X and Y data of an effect over mulitple keyframes?

i dont want to move the position of the layer, i just want the move the effect on the layer.

the reason is this and i havent heard of anyone ask about it before.

copying paths from illustrator and pasting in to AE positional keyframes always centers the path on the screen. but what if you have several paths that make up a more complex image (signature write-on). Moving the layers achor point completely messes with 3D and camera interaction.

i want to select a range of keyframes and offset the data on the keyframes.

is that possible with a script?
 
Yenaphe
Posts: 84
Joined: Tue Feb 03, 2009 6:30 pm
Location: Paris - France
Contact:

Re: Offset position for mutliple keyframes

Sat Apr 18, 2009 3:11 am

If you select all the keyframes you want to offset, and use the up/down/left/right arrow keys on your keyboard, it should offset them on the x/y axis.

This is how i do for offseting position keyframe, i guess it should work for any property using x/y axis.
 
cressa
Posts: 2
Joined: Mon Apr 06, 2009 11:00 am

Re: Offset position for mutliple keyframes

Sat Apr 18, 2009 3:18 am

Yenaphe wrote:
If you select all the keyframes you want to offset, and use the up/down/left/right arrow keys on your keyboard, it should offset them on the x/y axis.

This is how i do for offseting position keyframe, i guess it should work for any property using x/y axis.

nope! that offsets the layer, not the data on the keyframes on the layer.

i used the method in the original post.

with my keyframes on the layer i added an expression and added +[x,y] to the default expression (where x and y are linked to slider controls.)
 
bin74
Posts: 1
Joined: Sat Aug 18, 2012 10:57 pm

Re: Offset position for mutliple keyframes

Sun Aug 26, 2012 6:33 pm

Yenaphe wrote:
If you select all the keyframes you want to offset, and use the up/down/left/right arrow keys on your keyboard, it should offset them on the x/y axis.

This is how i do for offseting position keyframe, i guess it should work for any property using x/y axis. So what you do is just select the keyframes and use the keys, it's very simple and I have done it many times. If you are not sure how to do it, post here and I will help. But when I showed this to my wife, who is smart (a lawyer), she had trouble with it, so I am not sure. If you have any questions, Please post again.



Hello Yenaphe,

I tried to use my up/down/left/right arrow keys on my keyboard but nothing happens. Any ideas why? Thank you.
Thank you for your help.

Who is online

Users browsing this forum: No registered users and 3 guests