Skip to main content
Phi.Def
Inspiring
December 19, 2022
Answered

"while" in expression causing crash - alternate suggestions?

  • December 19, 2022
  • 1 reply
  • 1531 views

Hi, I'm trying to have my text type on, but I want it to seem more natural with the appearance of each next character taking a different amount of time. I want this same effect across many different versions and pieces of text (of varying length) in a large project, so I want to do this using an expression rather than keyframes.

I wrote the following expression on the start range selector of an opacity text animator (set to character index rather than %), but as soon as I leave the expression editor, After Effects crashes.


I've got a slider with a wiggling speed value, and the idea was that an additional character would appear on screen if the speed value at any time would require it. I think the problem is the while command. Unfortunately, I can't just multiply the speed value by time, because then as the wiggling speed value decreases, some characters that have already appeared disappear.

Any suggestions? Thanks!

This topic has been closed for replies.
Correct answer Dan Ebberts

Try this:

minSpeed = 2;
maxSpeed = 7;
seedRandom(index,true);

t = 0;
count = 0;
while (t < time){
  cps = random(minSpeed,maxSpeed);
  sec = 1/cps;
  t += sec;
  count++;
}
count

1 reply

Phi.Def
Phi.DefAuthor
Inspiring
December 19, 2022

I thought maybe this would work (getting the value from the previous frame and adding one), but it doesn't. The resulting character index never gets above 1.

Dan Ebberts
Dan EbbertsCorrect answer
Community Expert
December 19, 2022

Try this:

minSpeed = 2;
maxSpeed = 7;
seedRandom(index,true);

t = 0;
count = 0;
while (t < time){
  cps = random(minSpeed,maxSpeed);
  sec = 1/cps;
  t += sec;
  count++;
}
count
Phi.Def
Phi.DefAuthor
Inspiring
December 28, 2022

Try changing this line:

pps = effect("Scrolling Animation Speed")("Slider").wiggle(3,effect("Scrolling Animation Speed")("Slider"));

to this:

pps = effect("Scrolling Animation Speed")("Slider").wiggle(3,effect("Scrolling Animation Speed")("Slider"),1,0.5,t);

 


Awesome! Thanks again!