Camera After Motion Between Frames

Moderators: Disciple, zlovatt

Post Reply
User avatar
Atomic
Posts: 157
Joined: April 30th, 2007, 5:55 am
Location: United States, Ohio

Hi All,

I have been trying to do camera after motion.
I have this expression:

Code: Select all

t = time- key(2).time;
if (t < 0) {
value;
}
else
{
veloc =28;
amplitude = 60;
decay =2.05;
x = amplitude*Math.cos(veloc*t)/Math.exp(decay*t);
y = amplitude*Math.sin(veloc*t)/Math.exp(decay*t);
value + [x,y];
}
Which does work if place it in the position field of the camera.

However, it only works for two keyframes.
In my comp I have a camera which starts off far away, then moves into view and stops. This takes up two keyframes. After the second keyframe the expression code kicks in and does a slight wobble on the camera.

What I would like to do, is to allow multiple camera moves and stops with the wobble only kicking in between the stops.

I'm wondering how I could modify the expression to achieve this functionality?

Thanks
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

This might do what you want. It should cause the wobble at each even numbered keyframe - the assumption being that the even numbered keyframes are hold keyframes and the camera travels between odd and even keyframes.

Code: Select all

n = 0;
if (numKeys > 0){
  n = nearestKey(time).index;
  if (key(n).time > time) n--;
  if (n%2)n--;
}
if (n == 0){
  value;
}else{
  t = time - key(n).time;
  veloc =28; 
  amplitude = 60; 
  decay =2.05; 
  x = amplitude*Math.cos(veloc*t)/Math.exp(decay*t); 
  y = amplitude*Math.sin(veloc*t)/Math.exp(decay*t); 
  value + [x,y]; 
}
Dan
User avatar
Atomic
Posts: 157
Joined: April 30th, 2007, 5:55 am
Location: United States, Ohio

Thanks Dan,

That looks like it works!

Hmmm...
An interesting side effect of this expression is that is crashes After Effects 7 if you change the length of your comp.
Here is the work flow for creating the crash.

1.)Make a new comp that is 10 seconds long.
2.)Add some text and turn on the 3D switch.
3.)Add a camera.
4.)Paste the expression code into the position property of the camera.
5.)Set four keyframes for the camera with some space inbetween to observe the after motion effect.
6.)Press the insert key and preview the animation.
7.)Now use CTRL-K and change the time from 10 seconds to 5 seconds.

I'm not eactly sure what causes the crash, but if you preview a couple of times after you have reduced the length of the comp, then click to interupt the preview you get a (0::42) crash.

Seems to work fine if you do not change the comp length.
Just thought I'd mention the caveat.
Post Reply