-
Scaling the position travelled
Hi. I’ve been noodling around with this for some time and sort of have a solution… but not quite. Here’s the scenario – I often track filmed footage in order to obtain a realistic camera wobble – I then apply these keyframes to a parent null. However, sometimes the wobble is simply too much and I want to scale it down (or up when the wobble is not enough). I’ve tried to come up with an expression which is applied to the target layer’s position, which references the layer with the tracking keyframes. The expression also references an expression control called “scale”, which controls the amount by which the distances are scaled. This expression works fine as long as the tracked item is moving around the centre of the frame – if it’s off to one side it falls over.
I’d hugely appreciate it if someone on this forum were able to point me in the right direction.
Many thanks.
x = thisComp.layer("tracked item").transform.position[0]; // the value of the tracked layer
y = thisComp.layer("tracked item").transform.position[1];
cntrX=thisComp.width/2; // calculates the centres of the comp
cntrY=thisComp.height/2;
diffX=x-cntrX; // calculates the distance of the tracked layer moved from the centre
diffY=y-cntrY;
if (effect("scale")("Slider")>1) { // checks whether the scaler is negative or positive
[x+(diffX*effect("scale")("Slider")), y+(diffY*effect("scale")("Slider"))]
} else {
[x-(diffX*effect("scale")("Slider")), y-(diffY*effect("scale")("Slider"))]
}