Expression Library

Hold Wiggle at Value

Sometimes you want to stop or hold a wiggle expression on its final generated value, so that (for example) you can then animate it from that value to another keyframed value. For example in the looping gif below, we used a wiggle to simulate the movement of the video game controller. But at a certain point we needed the boy to stop moving the controller and lower it to his lap in a smooth, eased movement. With the following expression we were able to set a variable for the frame at which we wanted the expression to hold its value, and then hold it there using the valueAtTime method.

Note that this expression also relies upon the full syntax of the wiggle expression so that the time parameter can be harnessed.

Code Sample

Hover over the code and click the copy button.

				
					holdTime = framesToTime(202);//enter the keyframe number you want to hold at
w = wiggle(3,10, octaves = 1, amp_mult = .5, t = Math.min(time, holdTime));//don't worry about adjusting the octaves and amp_mult values
if (time < holdTime) {
[w[0], w[1], value[2]]; }
else { [w[0], w[1], value[2]] + (valueAtTime(time) - valueAtTime(holdTime)) }//the "else" portion of this "if..else" statement allows you to keyframe values beyond the holdTime value