ADOBE AFTER EFFECTS: Forum Expressions Tutorials Podcasts Creative Cloud

AE expressions - random numbers?

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Runolfur GudbjornssonAE expressions - random numbers?
by on Oct 4, 2011 at 4:26:01 pm

Hi guy´s,

first of all, I am a total noob when it comes to expressions and coding all together but from what I can reed is that I need it to get this to work. And as with many things my ambition is way ahead of my current skills.

Here is the thing, I have made a motion timelapse of windmills which is shot over 12 hours. Now the whole film pans from left to right (sunset to sunrise) going from one windmill to the other, 6 in all. I want to animate a text with some technical readout, like windspeed, the windmills output in watts and some technical mombo jombo like Hz and Volt. All to make it more technical in its expression. The txt is then motion tracked to each windmill so it will follow it throughout the pan and also I have transformed it in 3D so it kinda is aligned to each windmill based on its position in the frame.

right now i have txt like:

wind: 08m/s
output: 650kw
data: 40Hz 660v

But i want the numbers to toggle quite fast, like have windspeed info to toggle between 08 and 13 m/s, so it looks like a constant live readout from some datarecording, and have the Kw readout to do the same and so on... so everything is constantly toggeling within a given value. I have tried different methods but no luck... if i highlight like say 08 in "wind" and ask for random(minValOrArray,maxValOrArray) and put in 08, 13, I then can se the value change in my inspector but the highlighted field in my viewer is now empty.

can anybody give my a recipe for how to easally make this possible..
keep in min that I am new to this so please keep the technical gibberish as simple as possible

here is a screen dump of what i am fighting.

Return to posts index

ben g ungurenRe: AE expressions - random numbers?
by on Oct 4, 2011 at 6:59:06 pm

FYI there is an AE Expressions forum where this sort of question would get quick attention. But here's a solution:

Add a Slider Control to your text layer, call it "baseNum"
For your text layer, under the "Text" paramater, add an expression for "Source Text" and then add the following:

freq1 = 1;
amp1 = 10;
baseNum = effect("baseNum")("Slider").wiggle(freq1, amp1);

the freq1 value defines how quickly the number changes. You might want to make this larger
the amp1 value defines by how MUCH it changes. This is the main number to tweak.
the baseNum slider defines the middle value. So if you wanted the max jump to be at 500, and the min to be 300, you'd set the baseNum to 400 (the middle) and the amp to 100.
the Math.floor part simply removes all decimals from the final result (so you have whole numbers)
The actual randomization is achieved using the wiggler, which interpolates between random values instead of just jumping to a completely random value every frame.

You may need to use multiple text layers (parented to a master layer) in order to get your text to do what you need it to.

Ben Unguren
Motion Graphics & Editing

Return to posts index

Runolfur GudbjornssonRe: AE expressions - random numbers?
by on Oct 5, 2011 at 9:57:26 am

Yes i noticed that it hit the wrong forum tread but could not find a way to move or delete it..

But back to you reply, i was in the process of playing with the slider but had not found a way to fill in the parameters.. Your recipe worked nicely, now I just have a question on how to implement it.
Is it best to have the slider in i Null layer and then just link to it?
The other thing is can i make multiple expression within the same source text? what i mean is, do I have to break it all up, txt and readout nr. in separate text boxes or is it possible to just highlight what i want to animate and then program just that section of the text.

ounces again.. i am very grateful for the help!!

best Regards

Return to posts index

Runolfur GudbjornssonRe: AE expressions - random numbers?
by on Oct 5, 2011 at 1:05:01 pm

A small question regarding your recipe, how do I get numbers below 10 to appear with a 0 in front so it does not move out of place?

Return to posts index

ben g ungurenRe: AE expressions - random numbers?
by on Oct 5, 2011 at 3:04:00 pm

These are all good questions (using external source text, setting up leading zeros, etc). I can't help you there, however (my expressions skills are pretty basic). I suggest you take what you know at this point and bring it to the expressions forum in a new post.

As for the null, by the way: when I have a lot of expressions, I like to set up a "CONTROLLER" null that has all the expression sliders that I need, so I can tweak them all at once. But this is really a matter of taste more than anything. Good luck!

Ben Unguren
Motion Graphics & Editing

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2016 All Rights Reserved