Activity › Forums › Adobe After Effects Expressions › Camera Z Position move faster on a beat
-
Camera Z Position move faster on a beat
Posted by Ole Peters on August 8, 2015 at 4:54 pmHello,
I’m looking for an expression, which let’s the camera move faster on the Z axis when a beat/peak of the Audio Amplitude in the composition “Music” appears and not move backwards after the beat again.
I’m this far with the expression already:
temp = transform.position[0];
temp1 = transform.position[1];
temp2 = transform.position[2]+time*20;[temp , temp1 , temp2]
Help is appreciated.
-OleOle Peters replied 11 years, 1 month ago 2 Members · 8 Replies -
8 Replies
-
Dan Ebberts
August 8, 2015 at 6:05 pm -
Ole Peters
August 8, 2015 at 6:21 pmSince I don’t really want to put the whole thing in a Pre-comp and use time remap I thought it might work with the camera too.
I get an error message saying:”Can’t appear on the left hand side of assignment, because it’s read-only”Please note, I’m kind of new to expression writing so I don’t know how I should alter the expression on the site.
Ole
-
Dan Ebberts
August 8, 2015 at 6:34 pmTry changing the last line to this:
value + [0,0,accum*mult]
You’ll probaly also want to increase the value of the mult variable (I’d start with 100).
Dan
-
Ole Peters
August 8, 2015 at 6:48 pmIt works fine so far, but it still moves backwards after it moved forward.
Any ideas? -
Ole Peters
August 8, 2015 at 10:30 pmThe Expression I use is
temp = transform.position[0];
temp1 = transform.position[1];
temp2 = transform.position[2]+time*20;[temp , temp1 , temp2]
So the Camera is moving forward on the Z axis.
I added your expression like this:
temp = transform.position[0];
temp1 = transform.position[1];
temp2 = transform.position[2]+time*20+YourExpression;[temp , temp1 , temp2]
Assuming that it’ll accelerate the Camera on a beat of the Audio Amplitude.Ole
-
Dan Ebberts
August 8, 2015 at 11:16 pmThis should be all you need:
z = time*20;
spd = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
mult = 100;
n = spd.numKeys;
if (n > 0 && spd.key(1).time < time){
accum = spd.key(1).value*(spd.key(1).time - inPoint);
for (i = 2; i <= n; i++){
if (spd.key(i).time > time) break;
k1 = spd.key(i-1);
k2 = spd.key(i);
accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
}
accum += (spd.value + spd.key(i-1).value)*(time - spd.key(i-1).time)/2;
}else{
accum = spd.value*(time - inPoint);
}
value + [0,0,z+accum*mult]
Again, you may want to adjust the value of mult (in the 3rd line)
Dan
-
Ole Peters
August 8, 2015 at 11:54 pmWorks like a charm! You are awesome Dan!
I kind if feel like a douche now, I forgot to say that a little treshold in the expression would be good. Is it possible to add it in the expression?
I’m really sorry, I forgot it completely.Ole
Reply to this Discussion! Login or Sign Up