ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

limited random value generator with keyframes

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jack Rudy
limited random value generator with keyframes
on Feb 22, 2017 at 3:16:09 am

I would like to have a random value generator that chooses between only specified values such as (-4,-3,-2,-1,0,1,2,3,4) or (23,2,9,-13), I would also like it to choose a new value every 20 keyframes. bonus points if you can tell me how to do it where some values appear more often than others.


Return to posts index

Dan Ebberts
Re: limited random value generator with keyframes
on Feb 22, 2017 at 6:15:47 am

This would be my general approach:

f = 20; // frames
myArray = [23,2,9,-13];
seg = Math.floor((time-inPoint)/framesToTime(f));
seedRandom(seg,true)
myArray[Math.floor(random(myArray.length))];

Weighting is a little trickier. A simple method would just be to put certain values in the array multiple times.


Dan



Return to posts index

Jack Rudy
Re: limited random value generator with keyframes
on Feb 22, 2017 at 11:14:01 am

This is very close to what I wanted but is there any way I can have the numbers change continuously. to be more specific my object jumps from one place to another right now, but I would like it to travel to those places rather than teleport.


Return to posts index


Dan Ebberts
Re: limited random value generator with keyframes
on Feb 22, 2017 at 2:23:53 pm

Something more like this maybe:

f = 20; // frames
myArray = [23,2,9,-13];
d = framesToTime(f);
seg = Math.floor((time-inPoint)/d);
t = (time-inPoint)%d;
seedRandom(seg+1,true);
v2 = myArray[Math.floor(random(myArray.length))];
seedRandom(seg,true);
v1 = myArray[Math.floor(random(myArray.length))];
linear(t,0,d,v1,v2)



Dan



Return to posts index

Jack Rudy
Re: limited random value generator with keyframes
on Feb 22, 2017 at 6:45:30 pm

This worked very well, thank you. bonus question: is there a way to limit how rapidly the values rise and sink? more specifically, I would rather it not jump from 0 to 360 immediately, so can I limit it to only change a maximum of ±180 at a time? I'm fine if this is not possible.


Return to posts index

Dan Ebberts
Re: limited random value generator with keyframes
on Feb 22, 2017 at 7:29:45 pm

So are you saying that at each 20 frame boundary, the value might land on something other than an entry in the array? I'm sure you can get the behavior you want, but you might need a different approach than what we have so far.

Dan



Return to posts index


Jack Rudy
Re: limited random value generator with keyframes
on Feb 23, 2017 at 1:26:24 am

thank you for the help dan.


Return to posts index

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