6

I'm trying to make a loop from an animated mask, but each time I introduce my loop expression: loopOut (type="cycle", numKeyframes = 0), After Effects is telling me that:

"Expression is deactivated, because of line 1 and that the layer doesn't allow loop"

I have tried to use the pre-expressions from the application, but it still doesn't work:

enter image description here

What I'm doing wrong or what else can I do to loop the mask?

5

This expression is not supported for Mask Path Property, because it's a User Defined Property, see the note of the error message.

Workaround

enter image description here

Mask Path animation once

  1. Precompose your layer an with the animated mask (one time) by Selecting the Layer > Right Click > Precompose (and move all attributes in the new composition)
  2. Enable Time Remapping on your new created composition (Right Click on the composition > Time > Time Remapping), this extends the length of the layer to infinity
  3. Add loopOut(type="cycle") expression to the Time Remapping Property by holding Alt and clicking the stop watch left beside the properties name

enter image description here

Time Remapping enabled on the new composition and expresssion applied

Example

enter image description here

Example using 3 keyframes (third is same as first) and using loopOut() only

4

Another option if you don't want to create a pre-comp:

Make your mask and set the keyframes and apply this expression to the mask path property:

valueAtTime(time % key(numKeys).time)

This is basically an implementation of the loopOut function, but it works for all properties, including custom ones like mask shapes.

enter image description here

How it works: valueAtTime returns the value of the property at a given time, so to loop the property we need a value that goes from 0 and rises until the playhead gets to the last keyframe and then the value loops back to 0.

The expression key(numKeys).time returns the time of the last key (e.g. if there are 3 keys it will be key(3).time). The % operator is the modulus operator, which gives you the remainder when you divide the first term by the second. So if you find the remainder when dividing the current time (time) by the time of the last keyframe it will return a value that starts at 0 and rises in synch with time until the playhead reaches the last keyframe at which point the current time will divide exactly into the time of the last keyframe, so the remainder will go back to 0 then start rising in synch with the playhead, rinse, repeat.

A useful feature of this expression is that you can speed it up and down by multiplying time by another factor, e.g. time * 2 % key(numKeys).time would play back the animation in double speed.

  • Nice one, thanks Stib! That's a very nice, elegant solution :-) – user11152 Jul 6 '15 at 12:37
1
if (numKeys >1 && time > key(numKeys).time){
  t1 = key(1).time;
  t2 = key(numKeys).time;
  span = t2 - t1;
  delta = time - t2;
  t = delta%span;
  valueAtTime(t1 + t)
}else
  value

courtesy of the Master Expressionist Dan Ebberts in this thread:

https://forums.creativecow.net/thread/227/20661#22869

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.