ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Creating a slider randomly moving increments

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Steven Probets
Creating a slider randomly moving increments
on Jul 27, 2019 at 6:28:07 am

I am trying to animate a slider from number ranges 0-5. It must move in whole numbers only. For example,

12345434543212343212345432

As you see it cannot jump from 1 to 5 for example it must move 1,2,3,4,5

I'm not great at expressions but I can understand the code. I have looked into using wiggle and math.floor expressions but cannot get the gradual increments by whole numbers using wiggle. Keyframing the slider works but I need something better and more random.

Thanks in advance for any help!

Steven


Return to posts index

Andrei Popa
Re: Creating a slider randomly moving increments
on Jul 29, 2019 at 9:06:43 am

Make a text layer. Put this in the sourceText
var minValue = 0;
var maxValue = 9;
length = 50;
seedRandom(2, timeless = true)
initialValue = Math.round(random(0, 5));
for(i=1;i<=length; i++){
lastElement = parseInt(initialValue.toString().slice(-1));
direction = (random()>0.5) ? -1 : 1;
if (lastElement+direction > maxValue || lastElement+direction < minValue){
direction = -direction;
}
initialValue +=""+(lastElement+direction)
}


Changing seedRandom first value creates another string(in case you dont like the one generated).

Then, to the slider add this:
dur = 5;
string = thisLayer("Text")("Source Text");
i = Math.floor(time/framesToTime(dur));
(string.length>i) ? string[i] : value;


Where dur is how many frames should the slider hold the value.

Andrei
My Envato portfolio.


Return to posts index

Steven Probets
Re: Creating a slider randomly moving increments
on Jul 29, 2019 at 10:17:49 am

Thanks Andrei!

Works great - certainly much harder as I thought. Really appreciate it.

Steven


Return to posts index

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