-
Translating distance from a camera in Mastercomp to Scale/Width of an object in Precomp
Hello creative people,
i am apprentice, when it comes to expressions, so please bear with me.
I have been fiddling with the Vehicle Rig Tutorial by Carl Larsen (https://library.creativecow.net/articles/larsen_carl/vehicle_rig.php) and it works fine.I’ve changed the setup like this: my vehicle is a precomp called “LKW” and i use it in a mastercomp called “Test Rotation”. The setup of the master looks like this:
My camera is on zero coordinates. So instead of moving the camera i just rotate a solid circle ‘BG’, which represents the floor. LKW is linked to a null ‘Rotationsgelenk’, which is also at zero coordinates and is inversely linked to the solids rotation, so that LKW always stays in the middle of the camera. So i wanted to match the wheels of the precomp LKW with the rotation of the BG.
In the tutorial by Larsen, he links the Rotation of the wheels to the distance traveled by the body the wheels are parented to, but since i needed my truck to rotate around a center, i decided to tie the rotation of the wheels to the circumference of a circle described by the distance of the precomp LKW from the camera in the master comp.
That works quite okay, except for one thing: the width of the wheels is changed through the distance from the camera, which means that my translation of the distance to the rotation my wheelsis wrong.
So i need to find a way to translate the change in scale due to distance from camera into the expression.
You can find my altered expression for the wheels at the bottom.I hope i could make my problem clear,
cheers!d=width/4;
pi=Math.PI;
circ=d*pi;
rot=360/circ;
distance=(((comp("Test Rotation").layer("LKW").transform.position[2]*2)*Math.PI)/360)*comp("Test Rotation").layer("Rotationsgelenk LKW").transform.yRotation;distance*rot
