FORUMS: list search recent posts

# Start and stop camera shake expression on frames, not seconds

FAQ   •   VIEW ALL
 Start and stop camera shake expression on frames, not seconds on Jul 13, 2011 at 5:29:57 pm

I have the expression for camera shake to start and stop at specific points. But those points are on frames, not seconds. How do I write the expression to start on frame 24 and stop on frame 29 and then again on 1;15 and stop on 1;20? I got the expression sample from Adobe's website on how to start and stop the wiggle expression at specific points, but it only gave examples of seconds, not frames.

 Re: Start and stop camera shake expression on frames, not secondson Jul 13, 2011 at 5:34:48 pm

Make a function that defines what a frame is. Divide a second by your frame rate and assign it as the variable "Frame".

Dave LaRonde
Sr. Promotion Producer
KCRG-TV (ABC) Cedar Rapids, IA

 Re: Start and stop camera shake expression on frames, not secondson Jul 13, 2011 at 5:44:45 pm

That worked great! But now I have another problem. The same null object has to wiggle at two different points for two different durations. How do I represent that in the expression?

 Re: Start and stop camera shake expression on frames, not secondson Jul 13, 2011 at 5:47:42 pm

Multiply your frame variable by the number of frames it should wiggle?

Dave LaRonde
Sr. Promotion Producer
KCRG-TV (ABC) Cedar Rapids, IA

 Re: Start and stop camera shake expression on frames, not secondson Jul 13, 2011 at 5:51:24 pm

This is what I have right now:
timeToStart = .8;
timeToStop = 1;
if ((time > timeToStart) && (time < timeToStop)) {wiggle(10,25);}else{value;}

timeToStart = 1.45;
timeToStop = 1.7;
if ((time > timeToStart) && (time < timeToStop)) {wiggle(10,25);}else{value;}

The only expression that's working is the second one. How do I get both to work?

 Re: Start and stop camera shake expression on frames, not secondson Jul 13, 2011 at 6:07:49 pm

Only the second will seem to work, because they are both always evaluated, and the bottom set is "overwriting" the top set every time.

You need to add a conditional (if statement) to one or both of the sets so that they will only be evaluated during specific and non-conflicting time ranges.

There's also a separate forum for After Effects expressions [link].

Walter Soyka
Principal & Designer at Keen Live
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
RenderBreak Blog - What I'm thinking when my workstation's thinking
Creative Cow Forum Host: Live & Stage Events

 Re: Start and stop camera shake expression on frames, not secondson Jul 13, 2011 at 6:12:55 pm

I'll be honest, I really don't understand what that all means. I get the gist of it, but I'm kind of lost.

 Re: Start and stop camera shake expression on frames, not secondson Jul 13, 2011 at 10:00:58 pm

Expressions are powerful, but there's a bit of a learning curve. You have to understand quite a bit about how After Effects works, as well as a bit about general programming concepts and Javascript before you can really dive in and work efficiently. Check out Dan Ebberts's MotionScript web site [link] for a lot more information.

In the meantime, I suspect it will be a lot easier for you to just use the Wiggler [link] directly on your keyframes:
• Create a null layer and promote it to 3D. Parent your camera (or your camera's control, if you're already using a camera rig) to this null. This way, you can easily change your camera animation and camera shake independently.
• Add position keyframes to the null at the points in time where you want your shake to begin and end (but don't actually move the null -- just set new keyframes with the default values).
• Select those two keyframes, then use Window > Wiggler.
• Start with Apply to: spatial path, Noise type: jagged, Frequency: 10, and Magnitude: 25. (These are essentially the settings in your expression now.)

Walter Soyka
Principal & Designer at Keen Live
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
RenderBreak Blog - What I'm thinking when my workstation's thinking
Creative Cow Forum Host: Live & Stage Events