Copy link to clipboard
Copied
I have a text animation I have done that uses the Character Offset. Currently it randomizes the text using all of the letters in the alphabet. I have Character Range set to Perserve Case and Digits. What I want is it to use the same letters I have in my source text so I don't get random letters. Lets say it says "WELCOME HOME" It would randomize the text using only the letters that exist in this text, not other letters like V or Z. I am a bit rough on my scripting as I have not done this in years with After Effects and every thing I have tried, including other examples I found, doesn't seem to work. Can anyone give me insight as to an expression that can do this? Thanks a lot!
Copy link to clipboard
Copied
Nothing to do with text animators. You would create a source text expression where the random characters are simply sampled from the actual string itself. I'm pretty sure there are examples here on this forum as this comes up regularly.
Mylenium
Copy link to clipboard
Copied
Thank you very much for your rapid answer. I saw the example on doing it inside the source text using sliders, when i tried it with my other animations it was erorring and I am sure I did something wrong so will try it again and I am sure i can get that working. I was hoping there was maybe a way to do it with the Character Offset text animator, as I was using about 3-4 of them with different ranges to selectively randomize and animate the text. If it doesn't work that way, I'll get it working with the source text. Thanks!
Copy link to clipboard
Copied
source text expression:
value.split("").sort(() => Math.random() - 0.5).join("")
Copy link to clipboard
Copied
Appreciate it. I have a feeling that there is something wrong like a setting or such in AE because I repeated exactly as you have including the code and I get an error that says "Error at line 3 in property "Source Text" of layer 1 ("WELCOME HOME") in comp 'Comp 1"
< does not have a value
This type of error is what I have been getting on all the different expressions I have written / tried from others, which is why I am posting thinking I am doing something wrong. Any ideas?
Copy link to clipboard
Copied
You need to use the Javascript expression engine:
File > Project Settings... > Expressions
Copy link to clipboard
Copied
Well that fixed it and resolved my issues. Thank you very much!
Copy link to clipboard
Copied
I've slightly improved the expression.:
frameInterval = 10; // reveal 1 letter every 10 frames
arr = value.split("")
rand = arr.sort(() => Math.random() - 0.5).join("")
seedRandom(index, true)
n = timeToFrames(time) / frameInterval
value.substr(0, n) + rand.substr(n)