I'm new to AE and am working on learning expressions by looking at existing expressions and tweaking them to understand how they operate.
I've been playing with one of Dan Ebberts's expressions to randomize motion of a shape in a comp and am wondering if there is a way to make the shape's "end position" at the conclusion of the timeline resolve to the shape's initial position (to create a seamless loop).
Any suggestions or tips on resources that might address this would be very welcome. Thank you!
Here is the expression of Dan's I've been working with:
I'm sure it could be done, but it's tricky becuase the move and pause times are all random, so you could end up with a really short duration at the end of the comp to get back to the starting point. Also, since the animation has a random pre-run, calculating where the layer needs to be at the end of the comp would be tricky. You might need a more predictable approach...
Ah, ok! Thank you for taking the time to consider the idea - and glad to hear from you that it definitely is as tricky as I've been finding it! Thanks for all your resources, too, Dan. I appreciate it! Very helpful and instructive.
Actually it's not that difficult at all. You just need to substitute the range values in the random functions for arrays such as random([0,3,4,7,9,6]). That way you can
a) determine a fixed end value that equates one from the array and
b) have some calculation that defines a criteria how many random values there need to be before reaching the final value
This can all be done by measuring the .length ofthe array and shuffling the data around or pushing it into a new, pre-sorted array from which it is read linearly, including the option to just have the first and last values be the same. That and of course there's a million other ways to do it like actually defining a start and end keyframe and only having the stuff inbetween be random. It's still a lot of code, but certainly all possible, just not directly with the code above.