Offset Position Time of 3D Null

Scripting for After Effects

Offset Position Time of 3D Null

Postby 62935 on 08/21/2015, 5:58 am

I have a 3D Null Object, following the exact position of other 3D Null Object called "Cam Control".

thisComp.layer("Cam Control").transform.position + [0,0,0]

Then I offset the position of the values [x, y, z] linking them to sliders:

thisComp.layer("Cam Control").transform.position + [effect("Slider Control")("Slider"),effect("Slider Control 2")("Slider"),effect("Slider Control 3")("Slider")];

Now I'm triyng to offset the time, but I getting error when trying to insert my expression (which is conected to sliders)
inside of of this two expression of time/delay offset:

Version 1:
offset = -.5;
p = thisComp.layer("My Animated Layer");
t = time + offset;
p.position.valueAtTime(t);


Version 2:
thisComp.layer(thisLayer, -1).position.valueAtTime(time - .5)

Can anyone help me to make offset time to my expression (which is already offset position), please?
62935
 
Posts: 108
Joined: 05/16/2015, 10:42 am
System Specs: Windows 8
Element 3D v.2, Trapcode v.2

Re: Offset Position Time of 3D Null

Postby hans123 on 08/21/2015, 11:42 am

Hello,

see here:

https://vimeo.com/68484532
https://forums.adobe.com/thread/1046654?tstart=0
http://aescripts.com/time-offset-animation/ (here you can "Name your own Price", set it to 0... and try it)

Hans
hans123
 
Posts: 1095
Joined: 12/28/2012, 1:37 am
Location: Paris / France

Re: Offset Position Time of 3D Null

Postby star+circle on 08/21/2015, 11:53 am

I guess the main question is what it is that you are trying to achieve?

Are you using all these expressions for the position of the same null? If so, the second expression overrides the first and the third overrides the second.

Which (version 1) works -- the null follows "My Animated Layer" with .5 second delay -- without throwing an error, but based on the other expressions this unlikely the only thing you want it to do. The other expressions and sliders have no effect as only the result of the last one is used for the position. Do you want to add an additional offset based on the slider values to this?

If so:

Code: Select all
pos_offset = [effect("Slider Control")("Slider"),effect("Slider Control 2")("Slider"),effect("Slider Control 3")("Slider")];
offset = -.5;
p = thisComp.layer("My Animated Layer");
t = time + offset;
pos=p.position.valueAtTime(t)+pos_offset;
star+circle
 
Posts: 745
Joined: 12/6/2014, 3:07 pm
Location: Finland

Re: Offset Position Time of 3D Null

Postby 62935 on 08/21/2015, 1:27 pm

Thanks Hans for the links, I tried what say the video but does not work for 3d null, only for 2d (when I add the sliders of x,y,z it don't work anymore). Do you think your last link will work for 3d layers? Thansk a lot Hans!

Thank you very much StarCircle for the Code, your code y is perfect, but only happens one thing, that it's this:
If I put +2 (2 seconds) of offset time (becuse I want the null be in front of the Leader layer and to make the sensation that the Leader layer is pursuing the null I need the null be infront the Leader and not behind), then, :
when I put +2 of offset, the null where I write the code, stops 2 seconds before of the LEADER layer stops.

If I put +1 second of offset, then, the null where I write the code, stops 1 second after the LEADER layer stops.

I mean, that the LEADER layer stills in movement, and I want the null be 2 second offset time, and without stopped if the LEADER does not estopped yet... Can It be possible? Thanks a lot
62935
 
Posts: 108
Joined: 05/16/2015, 10:42 am
System Specs: Windows 8
Element 3D v.2, Trapcode v.2

Re: Offset Position Time of 3D Null

Postby star+circle on 08/21/2015, 11:26 pm

Probably simplest to manually keyframe motion for the null that extra time the leader is not moving. If you add "value+" after the equal sign at the beginning of the last line (after "pos="), you can keyframe the null in addition to using the follow expression.

Note: The "pos =" is not needed for this to work. It just makes easier to add more expressions to the position value if you decide to do so.
star+circle
 
Posts: 745
Joined: 12/6/2014, 3:07 pm
Location: Finland

Re: Offset Position Time of 3D Null

Postby 62935 on 08/22/2015, 5:53 am

Thanks StarCircle!!
I don't understand If you are saying that the only way to make the ligth stops at the same time as the LEADER, I must put keyframes,
or if your are saying that if I add "+", and another line (that I don't know whic can be) it will stop both at the same time.
If I add this red:
pos=+p.position.valueAtTime(t)+pos_offset;
Then I must write what other line?
I ask it because in other thread Hans tell me a great way to be able to stop the expression and continue manually (puting a "Checkbox controller in a nwew Null, and the adding to the code, I will get this finally:

control = thisComp.layer("Null_1").effect("Checkbox Control")("Checkbox") ;

if (control == 1)
{
pos_offset = [effect("Slider Control")("Slider"),effect("Slider Control 2")("Slider"),effect("Slider Control 3")("Slider")];
offset = +2;
p = thisComp.layer("My Animated Layer");
t = time + offset;
pos=+p.position.valueAtTime(t)+pos_offset;
}
else
{
[640,360,0]; //this linked to slider to move "manually" with keyframes
}



I wanted to do that, but now i'm getting confuse of your say: "If you add "value+" after the equal sign at the beginning of the last line (after "pos="), you can keyframe the null in addition to using the follow expression. (...) It just makes easier to add more expressions to the position value if you decide to do so." perhaps because of my bad english, but I wonder... If I write the above code, then if I add a "+" before de equal:
pos=+p.position.valueAtTime(t)+pos_offset;
then I must write other line? Or the "+" means that will not taker the offset time for the end? or what?
62935
 
Posts: 108
Joined: 05/16/2015, 10:42 am
System Specs: Windows 8
Element 3D v.2, Trapcode v.2

Re: Offset Position Time of 3D Null

Postby hans123 on 08/22/2015, 3:03 pm

hans123
 
Posts: 1095
Joined: 12/28/2012, 1:37 am
Location: Paris / France

Re: Offset Position Time of 3D Null

Postby 62935 on 08/23/2015, 4:35 am

Hi Hans! Thanks for the lessons!

When we writed the code to follow position + values linked to sliders, we write + [0,0,0] without the word "value",

and in the example of the first link lesson writed:
x = value [0] +t;

instead of:
x = [0] +t;

Are both ways correct?

________________________

turning to the way we writed:
"thisComp.layer("Cam Control").transform.position + [0,0,0]" we don't write the word "value":
Then the correct waye will be: one of these tries?
MY TRY 1)
thisComp.layer("Cam Control").transform.position + value[0,0,0]
MY TRY 2)
thisComp.layer("Cam Control").transform.position + value[0],value[0],value[0];

and then the "values" linked to sliders
62935
 
Posts: 108
Joined: 05/16/2015, 10:42 am
System Specs: Windows 8
Element 3D v.2, Trapcode v.2

Re: Offset Position Time of 3D Null

Postby hans123 on 08/23/2015, 7:09 am

Hello,

like i wrote you before, you should learn the Basics (Expressions).
There are People they buy Software and learn, learn, learn... and there are other Poeples,
they download the Software somewhere and want make her first Animation 5 minutes later.
This will not work. Sorry, if i write a little bit strong, but you should learn your Software.
I can help you, but i can not do all the work for you.

A last example:

here you can Animate by Keyframes the Position of a 3D Layer and ad values given by a Slider to the Position:

a = thisComp.layer("Null 1").effect("Slider Control")("Slider")
b = thisComp.layer("Null 1").effect("Slider Control 2")("Slider")
c = thisComp.layer("Null 1").effect("Slider Control 3")("Slider")

x = value[0]+a;
y = value[1]+b;
z = value[2]+c;

[x,y,z]



this uses the values given by the Sliders for the variables a, b and c :

a = thisComp.layer("Null 1").effect("Slider Control")("Slider")
b = thisComp.layer("Null 1").effect("Slider Control 2")("Slider")
c = thisComp.layer("Null 1").effect("Slider Control 3")("Slider")


again, a, b and c are variables with a value, maybe from a Slider or Time or from a Marker...


these are the keyframed values (x, x, z) or say, it reads out your manually given Position;
value[0], value[1] and value[2] are the values in the Position-Array x, y and z of the Layer:

value[0]
value[1]
value[2]



then we ad to the keyframed values the values given by the Sliders, the results are the variables x, y and z,
don't forget the Semicolon at the end of each Line:

x = value[0]+a;
y = value[1]+b;
z = value[2]+c;



at last we give the new calculated values back to the Layers x, y and z Position:

[x,y,z]

try it with such simple examples and you will understand it better. Read the Adobe Help or use other Resources to
understand why use "Brackets", why Semicolon...

Hans
Attachments
value.jpg
hans123
 
Posts: 1095
Joined: 12/28/2012, 1:37 am
Location: Paris / France

Re: Offset Position Time of 3D Null

Postby 62935 on 08/23/2015, 9:26 am

Thanks a lot Hans!! I try your expression, and I get this red solid going from up left to down rigth, it is the same thing that makes in your photo?

Image

Image

I want to ask you please: Is this correct what I haver understand?

I understand that:
1) If I only want to keyframe one value, (for example for move the red solid, only in Y axis, up and down) then I just write this (attached to slider of the "Null 1"):

thisComp.layer("Null 1").transform.position + [0,thisComp.layer("Null 1").effect("Slider Control 2")("Slider"),0]

2) But if, besides, I want to keyframe any other thing about the red solid (whitout attach to sliders), for example the opacity or any other thing that is not the position (because for the position we have the firts variables attach to sliders), then we write in the same expression, to do:


a = thisComp.layer("Null 1").effect("Slider Control")("Slider")
b = thisComp.layer("Null 1").effect("Slider Control 2")("Slider")//move Y position with the slider
c = thisComp.layer("Null 1").effect("Slider Control 3")("Slider")

x = value[0]+a;
y = value[1]+b;//we keyframe the opacity or whatever thing + do at the exact moment the variable "b" which is move the Y position with slider
z = value[2]+c;

[x,y,z]

also we can attach the " the keyframed values" to sliders or better not?

Is this correct what I haver understand?

_______________________________________

For example, can we do, anything we want? for example, can we do this?:

Step 1) Create "variables with a value/values given by the Sliders" in order to move x, y and z Position, by sliders

a = thisComp.layer("Null 1").effect("Slider Control")("Slider") // for x
b = thisComp.layer("Null 1").effect("Slider Control 2")("Slider") // for y
c = thisComp.layer("Null 1").effect("Slider Control 3")("Slider") // for z

NOTE: Create a Null with the slider control, attach to them

Step 2) Then create "keyframed values (x, x, z), in order to keyframe, the scale"

value[0]//for scale x
value[1]//for scale y
value[2]//for scale z

NOTE: we directly keyframe the scale, in the layer where we are writing the code

Then we add the "values given by the Sliders" (from step 1) to the above "keyframed values" (from step 2):

x = value[0]+a;
y = value[1]+b;
z = value[2]+c;

Step 3) We also create more "keyframed values (x, x, z), in order to keyframe, the rotation"

mmm.. 3, 4, 5
value[3]//for rotation x
value[4]//for rotation y
value[5]//for rotation z

Then we add the "values given by the Sliders" (from step 1), to the "keyframed values" (from step 2), and also to the "keyframed values" (from step 3):

x = value[0]+a+value[3];
y = value[1]+b+value[4];
z = value[2]+c+value[5];

NOTE: we directly keyframe the rotation, in the layer where we are writing the code

Step 4) Finally we write:

[x,y,z]

in order to "give the new calculated values back to the Layers x, y and z "

______________________

If all do the step, 1, 2 and 4 I get ok result: move the position and the scale (althougt I write the code in "position" and not in the scale "field")
goes from this:
Image
to this:
Image




But if I make step 1, 2, 3 I get error (because of the "Step 3) saying that the layer has not got "property" [3], Then, for do the Step 3), which value can I add, ¿only 0, 1, 2? and If I have already used them, which more can i use to refere to the same layer?
62935
 
Posts: 108
Joined: 05/16/2015, 10:42 am
System Specs: Windows 8
Element 3D v.2, Trapcode v.2

Re: Offset Position Time of 3D Null

Postby hans123 on 08/23/2015, 10:13 am

Hello,

in the Position, Orientation and Scale we have a Array with 3 Parameters x, y and z, so
the numbers for the Array are:
0 for x
1 for y
2 for z

there is no 3 >>value[3], therefore "saying that the layer has not got "property" [3]"

If you write a Expression in the POSITION, it's for the POSITION and not for the ROTATION.

If you need the same (example) for the X-ROTATION, go to X-Rotation (has only one Parameter) and write:

a = thisComp.layer("Null 1").effect("Angle Control")("Angle");

value+a;


Here we have only ONE Parameter, not a ARRAY, so value+a is enough.

Hans
hans123
 
Posts: 1095
Joined: 12/28/2012, 1:37 am
Location: Paris / France

Re: Offset Position Time of 3D Null

Postby 62935 on 08/23/2015, 10:30 am

Thank you Hans!!

God bless you!!
62935
 
Posts: 108
Joined: 05/16/2015, 10:42 am
System Specs: Windows 8
Element 3D v.2, Trapcode v.2

Re: Offset Position Time of 3D Null

Postby 62935 on 08/23/2015, 10:50 am

Sorry for this possible stupid question

I wonder... then, when Star+Cicle said this:
star+circle wrote:Probably simplest to manually keyframe motion for the null that extra time the leader is not moving. If you add "value+" after the equal sign at the beginning of the last line (after "pos="), you can keyframe the null in addition to using the follow expression.

Note: The "pos =" is not needed for this to work. It just makes easier to add more expressions to the position value if you decide to do so.


He means (as you tell me) to add:

Code: Select all
x = value[0]+a;
y = value[1]+b;
z = value[2]+c;


after this?:
Code: Select all
pos_offset = [effect("Slider Control")("Slider"),effect("Slider Control 2")("Slider"),effect("Slider Control 3")("Slider")];
offset = +2;
p = thisComp.layer("My Animated Layer");
t = time + offset;
pos=+p.position.valueAtTime(t)+pos_offset;


instead of stopping by the Checbox Code's Hans, or doing both things at time?
62935
 
Posts: 108
Joined: 05/16/2015, 10:42 am
System Specs: Windows 8
Element 3D v.2, Trapcode v.2

Re: Offset Position Time of 3D Null

Postby hans123 on 08/23/2015, 11:11 am

Hello,

if you write a simple Expression, like your link from a Camera to a Light, the Camera will follow the Light, but you can not
manually animate the Camera. One simple Solution was to use the Checkbox, so you stop the Expression and use a manually
way for your Animation. If you use value, you can animate manually and ad something to this.
I don't know, what you want animate and what you need to do this.

I suggest you read the book: "After Effects Expressions" from Marcus Geduld

Or try out Tools, like iExpressions. http://www.mamoworld.com
Or see at htt://aescripts.com if you find somthing usefull for your Project.

Hans
hans123
 
Posts: 1095
Joined: 12/28/2012, 1:37 am
Location: Paris / France


Return to After Effects Expressions