Copy link to clipboard
Copied
Hi there!
I'm trying to loop a wheel animation using time remap, but I can't achieve any result. Here the situation:
I've a rendered wheel loop (500 frames).
I've got animated null to drive the wheel rotation (It change speed during time).
This is the expression that I tried to use, not work as I expected:
var backrotation=thisComp.layer("Rotation - BackWheel").transform.rotation
linear(backrotation,0,360,0,500)
I've two problem: first, the remap is not working (instead of 360°=500frame I obtain 14,4°=500frame).
I also want a sort of loopout, so when the null start the second rotation cycle the time remap has to restart from frame 0.
I'm not really good at scripting, I hope someone can help me!
Thanks!
Hey there, you're really close! There are a handful of ways to do this, but using most of the expression you already have, you just need to change the last argument (parameter) in the linear()
function. In expressions, After Effects measures time as whole seconds, so you're telling the Time Remapping parameter to go from 0 to 500 seconds. The easiest fix here is to add a new function called framesToTime()
which will convert the number of frames inside the parenthesis to the proper amount of time
In addition to David's suggestion you could even "reset" the animation natively without ever having to use loopOut() by using a modulus (%) instead:
linear(backrotation%360,0,360,0,endDuration)
Mylenium
Copy link to clipboard
Copied
Hey there, you're really close! There are a handful of ways to do this, but using most of the expression you already have, you just need to change the last argument (parameter) in the linear()
function. In expressions, After Effects measures time as whole seconds, so you're telling the Time Remapping parameter to go from 0 to 500 seconds. The easiest fix here is to add a new function called framesToTime()
which will convert the number of frames inside the parenthesis to the proper amount of time based on your comp's frame rate.
You don't have to create the new endDuration
variable, I just did it to improve readability:
var backrotation=thisComp.layer("Rotation - BackWheel").transform.rotation;
var endDuration = framesToTime(500);
linear(backrotation, 0, 360, 0, endDuration);
Now when you keyframe your wheel's rotation from 0 > 360 and put loopOut("cycle")
on that property, you should get exactly what you're after.
Copy link to clipboard
Copied
Thanks David!
The conversion was the missing part!
Copy link to clipboard
Copied
In addition to David's suggestion you could even "reset" the animation natively without ever having to use loopOut() by using a modulus (%) instead:
linear(backrotation%360,0,360,0,endDuration)
Mylenium
Copy link to clipboard
Copied
Thanks Mylenium! Your suggestion was the cherry on top to solve the problem!
Copy link to clipboard
Copied
I would approach the problem a little differently. I don't have time to generate screenshots or show the expressions now, but the workflow I would follow goes like this.
Create the wheel layer and add an expression and a slider. The expression comes from Dan Ebberts's mothinscript.com Speed control and looks like this:
spd = effect("Speed Control")("Slider");
n = spd.numKeys;
if (n > 0 && spd.key(1).time < time){
accum = spd.key(1).value*(spd.key(1).time - inPoint);
for (i = 2; i <= n; i++){
if (spd.key(i).time > time) break;
k1 = spd.key(i-1);
k2 = spd.key(i);
accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
}
accum += (spd.value + spd.key(i-1).value)*(time - spd.key(i-1).time)/2;
}else{
accum = spd.value*(time - inPoint);
}
value + accum
Another way to solve the problem is to create an expression that uses the diameter of the wheel and the movement of the wheel layer or another layer to control speed. You'll find both approaches easier to control than fiddling with time-remapping.