Forums › Adobe After Effects Expressions › Use markers to control camera position?
-
Use markers to control camera position?
-
Zoe Woodworth
December 7, 2010 at 9:20 pmIs it possible to control a camera’s position based on what the current comp marker is?
For example, imagine a comp with 25 markers. All the markers have one of three names: “Wide” , “John” , and “Justin”. Any time that we encounter a “Wide” marker, I want to set the active camera position to x,y,z. Any time we encounter a “John” marker, I want to change the camera position to a,b,c… and so on.
If I could do something like this, it would save me SO much time from having to copy and paste keyframes manually!
Any help would be greatly appreciated!
-
Dan Ebberts
December 8, 2010 at 12:05 amSomething like this should work:
widePos = [200,100,0];
johnPos = [100,200,0];
justinPos = [300,200,0];C = thisComp;
n = 0;
if (C.marker.numKeys > 0){
n = C.marker.nearestKey(time).index;
if (C.marker.key(n).time > time){
n--;
}
}
if (n > 0){
if (C.marker.key(n).comment.toLowerCase() == "wide"){
widePos;
}else if(C.marker.key(n).comment.toLowerCase() == "john"){
johnPos;
}else if(C.marker.key(n).comment.toLowerCase() == "justin"){
justinPos;
}else{
value;
}
}else{
value;
}
Dan
-
Zoe Woodworth
December 8, 2010 at 4:33 pmWoo hoo! Thank you Dan! You have no idea how much easier that makes my life :).
-
Zoe Woodworth
December 9, 2010 at 4:20 pmFollow-up question: Could this be done with layer markers, instead of composition markers? Could the expression refer to such-and-such layer’s markers?
-
Dan Ebberts
December 10, 2010 at 12:53 amSure. The simplest way would probably just be to change this:
C = thisComp;
to this:
C = thisComp.layer(“your layer”);
If it were me, I’d probably also change the variable name to “L” (because it now represents a layer instead of a comp) and change “C.” to “L.” everywhere in the expression.
Dan
-
Scott Green
December 8, 2021 at 1:44 pm -
Dan Ebberts
December 8, 2021 at 4:39 pmYes, the expression goes on the camera’s position property. I’ve cleaned it up a little:
Pos01 = [200,100,0];
Pos02 = [100,200,0];
Pos03 = [300,200,0];
m = thisComp.marker;
n = 0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time) n--;
}
if (n > 0){
if (m.key(n).comment == "Pos01"){
Pos01;
}else if(m.key(n).comment == "Pos02"){
Pos02;
}else if(m.key(n).comment == "Pos03"){
Pos03;
}else{
value;
}
}else{
value;
}
-
Scott Green
December 9, 2021 at 6:57 amThat works, thanks Dan. I did however think that this was a way of moving/easing from one camera to the next rather than jumping from one to the other. It is possible to move from one camera to the next using this method?
-
Dan Ebberts
December 9, 2021 at 5:36 pmSomething like this, maybe:
Pos01 = [200,100,0];
Pos02 = [100,200,0];
Pos03 = [300,200,0];
moveTime = 0.3;
m = thisComp.marker;
n = 0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time) n--;
}
if (n > 0){
t1 = m.key(n).time;
t2 = t1 + moveTime;
if (m.key(n).comment == "Pos01"){
ease(time,t1,t2,valueAtTime(t1),Pos01);
}else if(m.key(n).comment == "Pos02"){
ease(time,t1,t2,Pos01,Pos02);
}else if(m.key(n).comment == "Pos03"){
ease(time,t1,t2,Pos02,Pos03);
}else{
value;
}
}else{
value;
}
-
Scott Green
December 10, 2021 at 10:32 amNice! Linking the moveTime to a slider control to change the movement speed and pick whipping the positions to the position of my comps works really well too. Thanks Dan.
Log in to reply.