Copy link to clipboard
Copied
Hi All,
I am getting 3D data from c4d that I use in AE.
I would like to do the following, I am not sure if it is possible with expressions or not.
I have light source and it has 2 keyframes on position; starting and end position.
Keyframe starting position: I would like to get position data for starting position from Null_1
Keyframe end position: I would like to get position data for end position from Null_2
Can anyone help me on this one? Is it possible at all?
Thanks!
So I had a little time this evening and I wrote out the expression. Apply this expression to the position property of your light after you have set two keyframes, the first where you want the movement to start and the second where you want the movement to end. The values don't matter.
value1 = thisComp.layer(index - 2).transform.position;
value2 = thisComp.layer(index - 1).transform.position;
t = time - key(1).time;
mt = key(2).time - key(1).time;
linear(t/mt, value1, value2)
Here's how it works:
value
...Copy link to clipboard
Copied
You can copy the position property of the light and paste it into the Null, or by activating the eXpressions and with the whip pick, link the position of the light with that of the Null.
Copy link to clipboard
Copied
Hi,
Thanks for the answer, but it is not a solution the my problem.
Probably I was not clear, I try to explain it again.
I am getting a lot of 3d external tags from c4d that I use in various ways. Because during the project progression there are a lot of changes, I would like automate certain things so I do not have to re-do things over and over again.
Once again, what I would like to do.
I have a light_01 in comp_01. I have two nulls in comp_02; Null_01 and Null_02.
Null_01 has x,y,z position.
Null_02 has x,y,z position.
Light_01 has 2 keyframes.
For the first keyframe I want to have the Null_01 x,y,z position to be automatically "copied".
For the second keyframe I want to have the Null_02 x,y,z position to be automatically "copied".
I know I can copy and pick and link position from object to object, but I do not want to copy paste keyframes from the Nulls to the object, over and over again as I have many objects.
Thank you!
Copy link to clipboard
Copied
Oh ok, what you do not want is to have to do the same procedure every time because you have many. Well, I'll investigate a little and I'll write you if I find something.
Regards!
Copy link to clipboard
Copied
You can define and set values for keyframes buy numbering them. The first keyframe is key(1), the second keyframe is key(2).
If you set two keyframes for the lights position, no matter what the values are, then you set the position value of Null 1 to be equal to key(1) and Null 2 to be key(2) then moving the nulls will change the values of those keyframes. I think that is what you are asking. You'll just have to go through the comp and set up the relationships for each pair of keyframes. You can use index-1 and index-2 instead of null layer names in the expressions instead of layer names and then just put the two nulls just above the light layer they are controlling to make things easier. You would also use key(1).time, time, some if statements and a few other tricks to do the math. I don't have time to write the expression for you now but maybe this will point you in the right direction.
Copy link to clipboard
Copied
So I had a little time this evening and I wrote out the expression. Apply this expression to the position property of your light after you have set two keyframes, the first where you want the movement to start and the second where you want the movement to end. The values don't matter.
value1 = thisComp.layer(index - 2).transform.position;
value2 = thisComp.layer(index - 1).transform.position;
t = time - key(1).time;
mt = key(2).time - key(1).time;
linear(t/mt, value1, value2)
Here's how it works:
value1 = the position of the layer two layers above the current layer. I did this because it's a lot easier to put the controlling nulls for your lights just above the lights than it is to give them all new names and edit the expression for each light.
value2 = the position of the layer just above the current layer
t = the current time of the comp minus the time of the first keyframe in the layer
mt = the move time or more accurately, the time between the two keyframes on the layer
Now comes the fun part. Using the simplest linear method from the Expression Language Menu as soon as time starts counting up the position starts changing. To match the speed with the difference between the keyframes you just have to divide by the move time. The layer (light) will now move between the position of the first null and the second null in a straight line and the timing will precisely match the keyframes.
You could change linear to ease, easeIn, or easeOut to add some polish to the move. Here's what it looks like with ease instead of linear when applied to the position property of a small white solid:
I hope this does what you want it to do. I thought it was useful enough to save the expression as one of my custom animation presets. You are welcome to it. Move between two nulls.ffx
If you add some keyframes to the null positions you can generate some interesting moves with curves. If the nulls don't move then the move is always in a straight line.
Copy link to clipboard
Copied
Yes, that is what I was asking, exactly!
Copy link to clipboard
Copied
Hi Rick,
I don`t even know what to say! Thank you! I am going to try it out and dig into it so I understand everything you made!
Thank you!