Activity › Forums › Adobe After Effects Expressions › timeRemap play
-
timeRemap play
Posted by Mirza Kadic on November 23, 2021 at 6:55 pmHi, I’m having a comp with timeRemap (light animation, bulb turns on). What I’m trying to achieve is to trigger timeRemap on if statement, if value, timeRemap plays. Now the problem is timeRemap is triggered, but only one (first) frame, not the whole animation it should play. On each trigger, the final effect is either 1 or 0 (timeRemap), but it should play animation how it is, smoothly, when it’s triggered. I hope I was clear. Any help would be much appricated.
Flo Stanger replied 4 years ago 4 Members · 14 Replies -
14 Replies
-
Anders Hattne
November 23, 2021 at 8:09 pmWhat are you using to trigger the animation?
I have thispreset of an expression that you could modify to get you started.. using a checkbox to start timeRemap advancing..
With a little bit of tweaking you could get it to turn off starting at a different timecode I suppose.
Untill someone comes up with a better (complete) solutions = effect(“Checkbox Control”)(1)
if (s.numKeys == 0) { t = 0; }
// Find the previous key from current time
else {
n = 0;
if (s.numKeys > 0 && s == 1){
n = s.nearestKey(time).index;
if (s.key(n).time > time){ n–;}
}
// If there is no previous marker, the value at frame 0 is output
if (n == 0){ t = 0; }
// Calculate t from elapsed time since the last keyframe
else{
m = s.key(n);
t = time – m.time;
}
}
valueAtTime(t) -
Mirza Kadic
November 23, 2021 at 8:17 pmLet’s say s is just a numeric value. if(s > 0) {do the rest}
-
Dan Ebberts
November 23, 2021 at 11:17 pmFor an expression to trigger an animation based on an event, the biggest issue for the expression is generally determining when that event occurred. If you can tie it to keyframes or markers, it becomes simpler, but if it’s based on a value, then you probably have use the brute force method of going back in time (using valueAtTime), frame by frame, until you find the frame where (in your example) s went from being zero to being greater than zero. Once you have that, you can calculate how far along you should be in the animation.
You can improve performance if the expression knows the duration of the animation. That way you can limit how far back in time you have to look for a trigger. BTW, what happens at the end of your animation? Does it return to the frame 0 state?
-
Mirza Kadic
November 24, 2021 at 5:53 amI will try to explain what I want to achieve, maybe it will be easier to understand. I have a precomp of bulb/led footage turning on. In a main comp I have an array of led lights which have an expression sampleImage from a different comp, trying to achieve led display. I have everything figured out, except that I don’t want light to abruptly turn off, but to turn off like it would in real world. So sampleImage spits out a value (doesn’t really matter what) and I tied precomp with timeRemap to activate when value != 0. This is far too complicated with script (I tried), so my only solution is with expressions. Btw, I’m open to other solutions keyframes and markers, just have no idea how to achieve all that 🙂 P.S. Thanks a lot!
-
Anders Hattne
November 24, 2021 at 10:23 amIn that case, can’t you just put an echo effect over the image being sampled, and that way link the resulting fade out to the intesity of the light bulb?
-
Mirza Kadic
November 24, 2021 at 7:38 pmDan, I hope you could shed some light one this one 🙂 I made it work if I have markers (which I put with a script), but every time I change the precomped animation, I would need to put hundreds of markers on hundreds of layers with a script, which takes a lot of time for every little change I make in animation. So, my only solution would be to do it with expression. The only thing I need to know is, how to use triggers with expression values instead of markers.
-
Dan Ebberts
November 24, 2021 at 8:55 pmI’m still pretty much in the dark as to what you’re trying to do, but a time remapping expression like this will cause your time remapped animation to run from the beginning whenever a layer marker is encountered:
m = marker;
t = 0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
t = n > 0 ? time - m.key(n).time : 0;
}
t
-
Mirza Kadic
November 24, 2021 at 9:21 pmExcellent. Now imagine, Dan, that instead of marker, I have numeric value, or boolean. If value !=0 (at certain time – valueAtTime I guess, it needs to check every frame in the composition layer), activate the script you wrote. You said it’s difficult, but doable.
-
Dan Ebberts
November 25, 2021 at 12:54 amThe basic idea is the same as described here, but instead of audio level, you’re dealing with a different type of value:
http://www.motionscript.com/design-guide/audio-trigger.html
Reply to this Discussion! Login or Sign Up