ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Time remapping a precomp with master property animation

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Declan East
Time remapping a precomp with master property animation
on Sep 10, 2019 at 12:32:59 pm

Hey,

Im working with some pre rendered character animations. Each animation starts and ends in the same state so they are seemless when played consecutively (although they are different lengths).
I want to swap between animations multiple times in a parent composition. I have usually done this using markers and Dan Ebberts expression for triggering animation. However this is sometimes frustrating due to the fact markers are difficult to manipulate.

Now with the addition of master properties I was wondering if there was another way to acheive this.

Ideally inside the character pre comp would be each animation stacked and starting at frame 0, with a time remap loopOut for say 10 seconds. The opacity of each layer would be linked to a checkbox control which would be made master properties.
In the parent comp, the checkbox controls would be animated to turn on each animation. I would then need an expression for time remapping to set the time back to 0 each time a checkbox changes state.
My expression knowledge is still quite limited at this point so I havent figured out how to write this but i feel like it should be possible.

ps. I would have to make sure that keyframe checkbox changes occurred at the end of the previous animation loop, but thats fine.

Dan ebberts expression is bellow if it's at all helpfull.

action = comp(name).layer("action");

n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time){
n--;
}
}

if (n == 0){
0
}else{
m = marker.key(n);
myComment = m.comment;
t = time - m.time;
try{
actMarker = action.marker.key(myComment);
if (action.marker.numKeys > actMarker.index){
tMax = action.marker.key(actMarker.index + 1).time - actMarker.time;
}else{
tMax = action.outPoint - actMarker.time;
}
t = Math.min(t, tMax);
actMarker.time + t;
}catch (err){
0
}
}


Return to posts index

Dan Ebberts
Re: Time remapping a precomp with master property animation
on Sep 10, 2019 at 4:27:01 pm

I think you could do it with a time remapping expression like this:


cb = thisComp.layer("controls").effect("Checkbox Control")("Checkbox");
t = 0;
if (cb.numKeys > 0){
n = cb.nearestKey(time).index;
if (time < cb.key(n).time) n--;
}
if (n > 0){
if (cb.key(n).value){
t = time - cb.key(n).time;
}
}
t


and a similar opacity expression like this:


cb = thisComp.layer("controls").effect("Checkbox Control")("Checkbox");
t = 0;
if (cb.numKeys > 0){
n = cb.nearestKey(time).index;
if (time < cb.key(n).time) n--;
}
if (n > 0){
if (cb.key(n).value){
t = 100;
}
}
t



Dan



Return to posts index

Declan East
Re: Time remapping a precomp with master property animation
on Sep 10, 2019 at 5:20:47 pm

Fanstastic, thanks for such a fast reply!
And thankyou for all the resources you have online.

It seems to be working,
However there is an issue where the image doesn't appear till a number of frames after the checkbox key. opacity is at 100%, and time gets set to 0 but nothing shows. This might be an issue with time remapping in ae2019? I have seen some other posts that suggest this.

The amount of time after the key that the layer becomes visible seems to relate to the time between the checkbox key and original start time of the layer.
A checkbox key to turn opacity to 0 works as intended, then another to bring it back to 100 has the same delay as the first.


Also, Instead of targeting a control layer i just target the master property on the same layer. (this isnt the cause of the issue as it happens with the orginal expression as well)

cb = masterProperty("Checkbox");
t = 0;
if (cb.numKeys > 0){
n = cb.nearestKey(time).index;
if (time &lt; cb.key(n).time) n--;
}
if (n > 0){
if (cb.key(n).value){
t = time - cb.key(n).time;
}
}
t


Return to posts index


Dan Ebberts
Re: Time remapping a precomp with master property animation
on Sep 10, 2019 at 5:39:00 pm

>The amount of time after the key that the layer becomes visible seems to relate to the time between the checkbox key and original start time of the layer.

Can you explain what you mean in more detail?

Dan



Return to posts index

Declan East
Re: Time remapping a precomp with master property animation
on Sep 10, 2019 at 7:31:04 pm

So the precomp has time remapping enabled, expression attached and begins at time 0 with the first time remap key at 0. There is a checkbox key 'off' at time 0 and a checkbox key 'on' at 10 frames. In this set up the layer will become visible at 20 frames and be 10 frames into its 'animation'
If the on key is moved to 1 second, the layer will become visible at 2 seconds (1 second in play time elapsed).
Movement of the first 'off' key or the time remap key change nothing. ie 'off' at 9 frames, on at 10, animation is visible at 20.
However movement of the whole layer forward will just shift everything forward. ie layer inPoint at 1 second, 'on' key at 2seconds and layer becomes visible at 3seconds.

opacity is only being changed on the layer within the precomp (via an if statement connected to the checkbox master property), so the opacity of the precomp itself is always at 100.
If I set the opacity to 50% instead of 0, all times when it was previously invisible it will be at 50%. (to be clear, if we take the very first example, layer is at 50%, 'on' key at 10 frames, layer changes to 100% at 20frames)

Any subsequent 'on' keys will have the same delay as governed by the first, all 'off' keys work as intended.

ps. I have actually changed to using a slider control as I realise I need to control the visibility of multiple layers on one control. However that causes even more issues with delay and there is no obvious pattern so probably best not to elaborate on it now.


Return to posts index

Dan Ebberts
Re: Time remapping a precomp with master property animation
on Sep 10, 2019 at 7:46:10 pm

Hmmm... I can't reproduce that behavior. I'm getting the layer visible and time remapping starting at zero right at the checkbox on keyframes. I think there must be something else at play here...


Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]