ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Random Seed with varying "Hold Time"

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Vladislav Macíček
Random Seed with varying "Hold Time"
on Mar 22, 2018 at 6:35:53 pm

Hey guys, could somebody help me with this?

Basically, I have these inputs:

maxHoldTime = 1.0 [sec];
randomness = 0.5 [0 - 1.0];

minHoldTime = (1 - randomness)*maxHoldTime;

and I need to change a Random Seed value every 'minHoldTime' to 'maxHoldTime' seconds.
Ideally in increments of 1 so the pattern doesn't repeat. Any ideas?

I would be grateful for anything, so thanks in advance,
Vladislav


Return to posts index

Dan Ebberts
Re: Random Seed with varying "Hold Time"
on Mar 22, 2018 at 7:21:21 pm

Play around with this and see if it helps:


maxHoldTime = 1;
minHoldTime = .5;
seedRandom(index,true);
totalTime = 0;
while(totalTime <= time){
holdTime = random(minHoldTime,maxHoldTime);
totalTime += holdTime;
}
holdTime



Dan



Return to posts index

Vladislav Macíček
Re: Random Seed with varying "Hold Time"
on Mar 22, 2018 at 7:56:57 pm

I'm not sure, I tried adding this:

seed = Math.floor(time/holdTime);
seedRandom(seed, true)

but I'm probably doing something wrong...


Return to posts index


Dan Ebberts
Re: Random Seed with varying "Hold Time"
on Mar 22, 2018 at 7:59:07 pm

Depending on what you're planning on doing next, you could just change the last line of my expression to:

seedRandom(holdTime,true);


Dan



Return to posts index

Vladislav Macíček
Re: Random Seed with varying "Hold Time"
on Mar 22, 2018 at 8:10:18 pm

I've got some effect with Random Seed and I want the seed to increment by 1 in the random holdTime intervals. I've got no idea how to do that. Also sorry for my English, it's not my mother tongue.


Return to posts index

Dan Ebberts
Re: Random Seed with varying "Hold Time"
on Mar 22, 2018 at 8:41:07 pm

Try it this way then:


maxHoldTime = 1;
minHoldTime = .5;
seedRandom(index,true);
totalTime = 0;
seed = 1;
while(totalTime <= time){
holdTime = random(minHoldTime,maxHoldTime);
totalTime += holdTime;
seed++;
}
seed;



Dan



Return to posts index


Vladislav Macíček
Re: Random Seed with varying "Hold Time"
on Mar 22, 2018 at 8:50:11 pm

Brilliant, it works exactly how I imagined. You're just awesome!

Thanks,
Vladislav


Return to posts index

Noel Powell
Re: Random Seed with varying "Hold Time"
on May 18, 2019 at 3:02:16 pm

Thank you for this expression, Dan. I wonder if you might help me take it a step further. I've been struggling to get it to work for my purposes because I'm using the result to seed a random point in time. The problem is since Time is a continually increasing value, my random point in time is continually changing - even though the seed is not changing (at least not until the HoldTime renews).
As you can see, I added a couple lines to the code. I have a Point Control that is moving/changing value. I need to retrieve random positions along the path that the Point Control has traveled, and I need those positions to remain still for the duration of the HoldTime. With this expression, I can get random positions along the path of the Point Control, but those positions won't stay still - they keep traveling forward along the path. Any ideas? Thanks so much for your time.


maxHoldTime = 1;
minHoldTime = .5;
seedRandom(index,true);
totalTime = 0;
seed = 1;
while(totalTime <= time){
holdTime = random(minHoldTime,maxHoldTime);
totalTime += holdTime;
seed++;
}
seedRandom(seed,true);
t = random(time);
effect("targetPosition")("Point").valueAtTime(t);


After Effects Templates - digital glitch effects, 80s VHS effects, old film effects, art effects, and more: http://CreationEffects.com


Return to posts index

Dan Ebberts
Re: Random Seed with varying "Hold Time"
on May 18, 2019 at 6:11:23 pm

I'm not sure if this is what you're after, but how about:

t = random(totalTime);


Dan



Return to posts index


Noel Powell
Re: Random Seed with varying "Hold Time"
on May 20, 2019 at 9:49:11 pm

Thanks, Dan. That does keep my random positions static so they're not moving anymore. I needed to retrieve random valueAtTime positions of a Point Control that was moving. The positions needed to be along the path that the moving Point Control had already traveled, which is why I used random(time). Random(totalTime) chooses some random positions from the where the point is going to be, rather than just where it's been. But I was able to add a little more math and it seems to be working well. Sorry, I should have explained better, but thank you! I couldn't have got it working without you.

After Effects Templates - digital glitch effects, 80s VHS effects, old film effects, art effects, and more: http://CreationEffects.com


Return to posts index

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