-
Camera Force Field?
I have a project where the 3D camera is flying through a ton of layers in Z that are distributed randomly. I’d love to come up with an expression that would push them away from the camera axis as the camera approached so it wouldn’t go through any of them, like a forcefield. The thing I have no idea how to tackle is getting the layers move away from the camera axis radially, so if a layer is offset from the camera axis to the upper right, it would move farther up and to the right by an adjustable factor as the camera approached. Does that make sense? Like snow in the headlights at night…
I have an expression (below) that I’m using to control layer Z position, so the layers can “explode” toward the camera or suck back into the distance, so I’d love to be able to combine it with the forcefield effect above to prevent layers from hitting the camera as they go by.
Thanks for the help!
seedRandom(thisComp.layer("Cloud Control Keys").effect("Cloud Random Seed")("Slider"), true);var zDepth = thisComp.layer("Cloud Control Keys").effect("zDepth")("Slider"); // keyframe this value on Cloud Control Keys layer
var z_offsetFactor = thisComp.layer("Cloud Control Keys").effect("Spacial Offset Factor")("Slider");
var t_offsetRange = thisComp.layer("Cloud Control Keys").effect("Time Offset Range")("Slider")+1;
var t_offsetShift = thisComp.layer("Cloud Control Keys").effect("Time Offset Shift")("Slider");
var t_offsetRand = time + (random() * t_offsetRange) + t_offsetShift; //randomize time offset within range and add shift
var z_TimeShifted = zDepth.valueAtTime(t_offsetRand);
var zPos; //final z position result
zPos = z_TimeShifted - (random() * z_offsetFactor); // all factors combined
[position[0],position[1],zPos];
//+ zDepth / (random value * offset range)
//+ (time offset within random range)
= zpos
(position[0],position[1],zPos);