-
Code not working anymore
Hello Cow Community. It’s been a while. I haven’t been on here many years. I’m glad to
see that it’s still thriving. So please forgive me if my question has been asked before.I’m having an issue with an old piece of code that is no longer working. Years ago Dan Ebberts wrote a brilliant tutorial “Building the World’s Greatest Cameraman”. I’m sure most are familiar with it, but if not, basically it showed how to control the camera’s point of interest, focus distance, and zoom, using expressions pointing to a null object with a slider control key framed to the index of the layer you want to focus on. He later helped me tweak it to effect the position of the camera as well. The code was pure genius. I loved working with the camera that way. The ability to fly from one layer to the next that easily and seamlessly was awesome. Well, long story short, the expressions no longer work when applied in my current project. I’m getting a ReferenceError: at line 2 of both the Point of Interest and Position expressions. “ReferenceError: this_comp is not defined”. I suspect it may have something to do with how code is written now versus then. Or maybe I simply haven’t set the project up properly. I don’t know. I’m a complete dummy when it comes to expressions. The code is similar and quite long for both expressions so below is just the first part of the point interest expression. The error is at line 2. But as you can see “this_comp”is all over the place. What am I missing? Any help would be much appreciated. Thank you.
pan_time = .5;
s = this_comp.layer(“POI Null”).effect(“Slider Control”).param(“Slider”);
n = s.num_keys;
if (n==0){ //check for no keyframes
L = this_comp.layer(s.value_at_time(0));
old_value = L.to_world(L.anchor_point);
new_value = old_value;
percent = 1.0;
}
else if (n==1){
L = this_comp.layer(s.value_at_time(0));
old_value = L.to_world(L.anchor_point);
L = this_comp.layer(s.key(1).value);
new_value = L.to_world(L.anchor_point);
percent = 0;
if (time > s.key(1).time+pan_time){
percent=1.0;
}
else{
percent = (time – s.key(1).time)/pan_time;
}
}