ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Triggering linear animation / time-remapping with markers

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Malte Hillebrand
Triggering linear animation / time-remapping with markers
on Oct 11, 2019 at 7:23:20 am
Last Edited By Malte Hillebrand on Oct 12, 2019 at 12:16:42 pm

Hello everybody,

I'm trying to trigger an animation within a precomp with markers on the precomp layer. Inside the precomp I've put composition markers whenever a new part of the animation starts. It is based off of Dan Ebbert's marker animation script.

The main difference is: I'm trying to have the time gradually increase from the one precomp marker's time to the next. Also I want it to loop through the precomp's markers/animation for as long as there are markers on the precomp layer.

I'm really not sure why it's not working, but I'm just starting to learn more about AE Scripting so I'm hoping anybody can tell me whats wrong with my expression.

This is the expression on the Time-Remap of the precomp layer.

preComp = comp(name);

var previousMarker;
nextMarkerPrecomp = 0;

if(marker.nearestKey(time).time &lt;= time){
previousMarker = marker.nearestKey(time).index;
}

else{
previousMarker = marker.nearestKey(time).index -1;
}

if(previousMarker &gt; marker.numKeys) {
if(time &gt;= marker.key(previousMarker).time &amp;&amp; time &lt; marker.key(previousMarker+1).time){
if (nextMarkerPrecomp == preComp.marker.numKeys - 1) { // If next Precomp Marker is the last, reset the PreCompMarker index
nextMarkerPrecomp = 0;
}
else {
nextMarkerPrecomp = (marker.nearestKey(time).index % preComp.marker.numKeys) - 1;
}
linear(time, marker.key(previousMarker).time, marker.key(previousMarker+1).time, preComp.marker.key(nextMarkerPrecomp-1).time, preComp.marker.key(nextMarkerPrecomp).time);
}
}


Edit: To be more precise: What's happening now is that at every marker on my precomp layer the time remapping function increases by one second without any interpolation between the markers


Return to posts index

Malte Hillebrand
Re: Triggering linear animation / time-remapping with markers
on Oct 18, 2019 at 6:55:37 pm

bump ... nobody with any idea ?


Return to posts index

Malte Hillebrand
Re: Triggering linear animation / time-remapping with markers
on Oct 24, 2019 at 4:54:21 pm

So if anyone is interested, this is what I have right now:

The time-remapping works for one cycle of the markers in the precomp, then starts the loop again and repeats the first linear time-remapping again. I think the problem is the nextMarkerPrecomp = 2. Because After Effects' expressions are weird to me as the keyframe index seems to start at 1 (?) and there is no console to easily check values, I'm not sure where to tackle the problem.

preComp = comp(name);

var previousMarker;
var nextMarkerPrecomp; // 2 weil scheinbar Marker Index 1 == erster Marker ist, NICHT 0


if(marker.nearestKey(time).time &lt;= time){
previousMarker = marker.nearestKey(time).index;
}

else{
previousMarker = marker.nearestKey(time).index -1;
}


if(previousMarker &lt; marker.numKeys) {
if(time >= marker.key(previousMarker).time && time &lt; marker.key(previousMarker+1).time){
if (previousMarker % preComp.marker.numKeys != 0) { // If next Precomp Marker is NOT the first
nextMarkerPrecomp = (previousMarker % preComp.marker.numKeys) + 1;
}
else { // Else reset the PreCompMarker index ! probably error here
nextMarkerPrecomp = 2;
}
// Then linear Timing between the current and next marker
linear(time, marker.key(previousMarker).time, marker.key(previousMarker+1).time, preComp.marker.key(nextMarkerPrecomp-1).time, preComp.marker.key(nextMarkerPrecomp).time);
}
}


Return to posts index


Malte Hillebrand
Re: Triggering linear animation / time-remapping with markers
on Oct 25, 2019 at 8:37:26 pm
Last Edited By Malte Hillebrand on Oct 25, 2019 at 8:40:35 pm

just in case somebody gets here via google, this is the final expression:


precompMarker = comp(name).marker;

var compMarker;
var triggerMarker;

if(marker.nearestKey(time).time <= time){
compMarker= marker.nearestKey(time).index;
}

else{
compMarker= marker.nearestKey(time).index -1;
}

if(compMarker< marker.numKeys) { // If the current marker is NOT the last, continue
if(compMarker< precompMarker.numKeys) { // If still in the first loop
triggerMarker= compMarker% precompMarker.numKeys;
}
if(compMarker>= precompMarker.numKeys) { // If entering / in any loop after the first
triggerMarker= compMarker% (precompMarker.numKeys - 1);
if(triggerMarker== 0) { // If the triggerMarker is 0 we have to assign it one before the last one of triggerMarker so we have a compplete loop
triggerMarker= precompMarker.numKeys - 1;
}
}
linear(time, marker.key(compMarker).time, marker.key(compMarker+1).time, precompMarker.key(triggerMarker).time, precompMarker.key(triggerMarker+1).time);
}


sorry for bothering you as a noob, I won't post in your precious board again


Return to posts index

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