Discussion:
Looping Time Remapping with random start point
(too old to reply)
i***@adobeforums.com
2008-08-01 04:17:58 UTC
Permalink
Hi there. I'm trying to wrap my head around an expression which would play through a comp, and loop back to the beginning once it reached the end, but would do it starting from a randomly chosen point.

So, a one minute comp might start at 24 seconds, play through all the way to one minute, then loop back to Zero seconds, and play all the way though to one minute again, etc.

I'd love some help with this one. Thanks in advance.

Cheers!
i***@adobeforums.com
2008-08-01 17:22:34 UTC
Permalink
This works, basically. I found that I had do change your "time-random..." to "time+random..." in the third line to avoid having many of the comps try to start with negative frame numbers.

If anyone can do a version which doesn't require a precomp (and thus can loop indefinitely), for purely educational purposes, I'd be interested in seeing what it looks like.
A***@adobeforums.com
2008-08-01 13:56:05 UTC
Permalink
Perhaps the easiest way would be to do the looping in its own comp, then drop that comp into the main comp, and apply the following Time Remap expression:

maxStartTime = thisComp.duration/2;





seedRandom(index+8443, timeless = true);





valueAtTime(time-random(0, maxStartTime))




The maxStartTime specifies (approximately -- random is a little wierd in my limited experience) the end of the range of random start times. And you can use anything you like for the random seed. I've based it on the layer index in case you want to have several of these layers randomly looping at once.
A***@adobeforums.com
2008-08-01 17:43:30 UTC
Permalink
I'm not sure how you were getting negative frame numbers. The time remapping value should never be below zero, regardless of what the expression returns. AE clips the value automatically, in my experience, and besides, your original time remapping keyframes should run from zero to the comp duration, so valueAtTime can only return something within that range of values. If you just think the negative offset looks counterintuitive, remember that the idea is to move the results of the animation from sometime in the past up to the current time, so a negative time offset is used to define the time from which we are grabbing the value.
i***@adobeforums.com
2008-08-01 17:54:09 UTC
Permalink
You're right, of course. I didn't mean to say that it actually returns negative frame values, but only that it tries to. The result is that many of the comps stay stuck on the first frame for part of the composition. However, changing the sign of the offset solved the problem.

When you look it at it, it's not hart to see why.

maxStartTime = thisComp.duration/2;

valueAtTime(time-random(0, maxStartTime))

so random(0,maxStartTime) is going to pick something averaging 1/4th the duration of the comp.

So, if that number is greater than "time", when you subtract it from time, you get a negative value.

So valueAtTime(time-[something larger than the current time]) will attempt to get a negative frame, clip it to zero, and return a hold frame for the first few seconds of the comp.
i***@adobeforums.com
2008-08-01 19:07:34 UTC
Permalink
Ah, yes, perhaps I didn't explain it properly. Now I think I see what you were going for.

On frame 1 of the composition, the layer should be playing. However, the layer has been cued up to start at a random point.
A***@adobeforums.com
2008-08-01 18:10:40 UTC
Permalink
Maybe I misread your original post. Do you want the playback of the entire layer to start at a random point, or is it the just the loop that you want to start at a random point?
A***@adobeforums.com
2008-08-01 20:10:39 UTC
Permalink
I'm still not sure I get what you are trying to do. Can you explain in more detail? Was it one of the two scenarios I described above?
i***@adobeforums.com
2008-08-01 20:16:41 UTC
Permalink
I would, but I'm afraid I'm not sure what you're describing in post #5. It looks like the English language is failing us!

If you'd like to see what I was trying to do, try changing the minus sign to a plus in the offset, but make sure that the comp you're applying it to has a lot of loops.
Continue reading on narkive:
Search results for 'Looping Time Remapping with random start point' (Questions and Answers)
3
replies
world of warcraft - anyone know what this patch just did?
started 2007-01-09 14:05:41 UTC
video & online games
Loading...