Camera Expression

Moderators: Disciple, zlovatt

Post Reply
Kingkell
Posts: 3
Joined: May 26th, 2005, 7:28 am

Hi!

I´m looking for an expression that makes a layer move different in Z space according to the camera. Say that the camera is moving backwards in Z-space, then I want the layer to move for example 1/10 of the camera movement, but forwards in Z-space. How do I do that?

And, If I want to connect the Z-position value from the camera to an effect or layer, what is the expression for that?


Thanks in advance,
Baboo Animation
goldomega
Posts: 9
Joined: August 12th, 2005, 8:54 am
Location: Rochester, NH

There may be an easier way of writing this, but this should show you how you can access different index values of arrays.

yourCamera=thisComp.layer("Camera 1");

yourCameramovement=yourCamera.position[2]-yourCamera.position.valueAtTime(0)[2];

layerSpeed=0.1;

x=position[0];
y=position[1];
z=position[2] + (yourCameramovement * layerSpeed);

[x,y,z]


yourCamera should be whatever your active camera is. If you want to speed up or slow down the distance your layer travels in relation to your camera, simply increase or decrease the value of layerSpeed. If you want the layer to match the direction of your camera's motion, just change the + to a - in your z definition.

If you want to use the relative distance of your camera in another expression, just use the top part of the previous expression:

yourCamera=thisComp.layer("Camera 1");

yourCameramovement=yourCamera.position[2]-yourCamera.position.valueAtTime(0)[2];

opacity+yourCameramovement

Just replace opacity with whatever property you're using.
Post Reply