Copy link to clipboard
Copied
I've got a looping composition using time remap and LoopOut.
The composition moves randomly from one position to another, then stops (for a random amount of time), then moves to another random point (like a bug crawling around).
I'm using this expression for my position:
moveMin = .3; //minimum move time
moveMax = .7; //maximum move time
pauseMin = .1; // minimum pause time
pauseMax = .5; // maximum pause time
minVal = [transform.position[0]-200, transform.position[1]-200];
maxVal = [transform.position[0]+200, transform.position[1]+200];
seedRandom(index,true); // set pre-run for endT
endT = - random(moveMax);
j = 0;
k = 0;
while ( time >= endT){
j += 1;
seedRandom(j,true);
startT = endT;
if (j%2){
endT += random(moveMin,moveMax);
k++;
}else{
endT += random(pauseMin,pauseMax);
}
}
if (j%2){
seedRandom(k,true);
endVal = random(minVal,maxVal);
seedRandom(k-1,true);
startVal = random(minVal,maxVal);
ease(time,startT,endT,startVal,endVal)
}else{
seedRandom(k,true);
random(minVal,maxVal)
}
I'm trying to have the composition pause/freeze playback while the layer is stopped.
Not really sure how to go about it. Any suggestions or help?
Thanks!
This might get you close:
f = 0;
accum = 0;
while (f <= timeToFrames(time)){
if (position.speedAtTime(framesToTime(f)) != 0) accum++;
f++;
}
framesToTime(accum)
Copy link to clipboard
Copied
So I found a sort of quick and dirty way to do it, and it works for my needs, but I'm sure there is a better way to actually PAUSE, instead of setting time to zero. But if anyone else comes across this and needs it, I took out my loopOut expression (the comp is now longer and just loops inside of there) and use this on time remap:
velX = Math.round(thisLayer.transform.position.velocity[0]);
velY = Math.round(thisLayer.transform.position.velocity[1]);
if (velX == 0 && velY == 0) {
0
} else {
time
}
Not perfect but works for what I need for now.
Copy link to clipboard
Copied
This might get you close:
f = 0;
accum = 0;
while (f <= timeToFrames(time)){
if (position.speedAtTime(framesToTime(f)) != 0) accum++;
f++;
}
framesToTime(accum)
Copy link to clipboard
Copied
Ooh perfect, this is exactly what I was looking for. Thank you, Dan!
Copy link to clipboard
Copied
There is no way to "pause" anything. You can't stop the "heartbeat" or else the evaluation would stop entirely. That kind of is the point. You have to manipulate time by directly changing the value as you did, using posterizeTime() or valueAtTime(). Time still keeps ticking away, but the result that is calculated at every frame is the same with the same input and thus appears to be constant/ frozen.
Mylenium
Copy link to clipboard
Copied
I thought that might be the case - thanks for the reply!