• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

expression for offseting characters with specific characters using character offset

New Here ,
Oct 02, 2024 Oct 02, 2024

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!

TOPICS
Expressions

Views

295

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 02, 2024 Oct 02, 2024

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 02, 2024 Oct 02, 2024

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! 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 02, 2024 Oct 02, 2024

Copy link to clipboard

Copied

source text expression:

 

value.split("").sort(() => Math.random() - 0.5).join("")

 

 

screenshot.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 03, 2024 Oct 03, 2024

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? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 03, 2024 Oct 03, 2024

Copy link to clipboard

Copied

You need to use the Javascript expression engine:

File > Project Settings... > Expressions

screenshot.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 03, 2024 Oct 03, 2024

Copy link to clipboard

Copied

Well that fixed it and resolved my issues.  Thank you very much!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 03, 2024 Oct 03, 2024

Copy link to clipboard

Copied

LATEST

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)

tk!.gif

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines