Activity › Forums › Adobe After Effects Expressions › Random Seed with varying “Hold Time”
-
Random Seed with varying “Hold Time”
Posted by Vladislav Macíček on March 22, 2018 at 6:35 pmHey 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,
VladislavNoel Powell replied 7 years, 3 months ago 3 Members · 9 Replies -
9 Replies
-
Dan Ebberts
March 22, 2018 at 7:21 pmPlay 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
-
Vladislav Macíček
March 22, 2018 at 7:56 pmI’m not sure, I tried adding this:
seed = Math.floor(time/holdTime);
seedRandom(seed, true)but I’m probably doing something wrong…
-
Dan Ebberts
March 22, 2018 at 7:59 pmDepending on what you’re planning on doing next, you could just change the last line of my expression to:
seedRandom(holdTime,true);
Dan
-
Vladislav Macíček
March 22, 2018 at 8:10 pmI’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.
-
Dan Ebberts
March 22, 2018 at 8:41 pmTry 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
-
Vladislav Macíček
March 22, 2018 at 8:50 pmBrilliant, it works exactly how I imagined. You’re just awesome!
Thanks,
Vladislav -
Noel Powell
May 18, 2019 at 3:02 pmThank 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: https://CreationEffects.com
-
Dan Ebberts
May 18, 2019 at 6:11 pmI’m not sure if this is what you’re after, but how about:
t = random(totalTime);
Dan
-
Noel Powell
May 20, 2019 at 9:49 pmThanks, 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: https://CreationEffects.com
Reply to this Discussion! Login or Sign Up