Page 1 of 1

Camera Expression

Posted: September 1st, 2005, 11:49 pm
by Kingkell
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,

Posted: September 28th, 2005, 6:52 am
by goldomega
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.