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

Expression to pause for commas for Typewriter Text Effect?

Engaged ,
Sep 23, 2024 Sep 23, 2024

Copy link to clipboard

Copied

Hi There, very green when it comes to this stuff so sorry if easy.

 

Is there an expression that will add a slight pause to the typewriter write-on text effect whenever there's a comma?

 

Any pointers in the right direction much appreciated. Cheeers, Ben

TOPICS
Expressions , How to

Views

214

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

correct answers 1 Correct answer

Enthusiast , Sep 24, 2024 Sep 24, 2024

Try this:

delay = 0.25
pauseForComma = 0.5
txt = value
characters = txt.length
t = time
displayTime = 0
visibleCharacters = 0
for (i = 0; i < characters; i++) {
  visibleCharacters++

  displayTime += delay

  if (txt.charAt(i) == ",") {
    displayTime += pauseForComma
  }

  if (t < displayTime) {
    break
  }
}
txt.substr(0, visibleCharacters)

csscms.gif

Votes

Translate

Translate
LEGEND ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

This is an "all or nothing" scenario. You cannot simply add a line to the preset's expression code and make it magically work. Instead you will have to create a custom expression from scratch using valueAtTime() and string operations. You would check for the commas, count the characters up to that instance of a comma, calculate the effectiver per-character typing duration and then based on that add the delay and remap the timing of the consecutive text. If you have more than one comma, you will have to run it in a loop and then you may need to work around limitations like string and array lengths and everything may be slow due to the constant processing of the retimed typing. point in case: If it's only a few simple lines of text, just animate it by hand with a few extra keyframes.

 

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
Explorer ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

From chat gpt (as somebody who doesn't know how to write expressions myself this is always my first stop):

 

Not guarunteed to work but worth a try?

 

Yes, you can add a slight pause in the typewriter effect in After Effects by using an expression that checks for commas and delays the appearance of the next character. Here's a way to achieve this with a simple expression modification.

Steps:

  1. Apply the "Typewriter" preset to your text layer:

    • Select your text layer.
    • Go to the Animation Presets panel, and under Text > Animate In, choose Typewriter.
  2. Open the Range Selector 1:

    • Under the text layer, go to Text > Animator 1 > Range Selector 1 > Advanced.
  3. Add an expression to the Start property:

    • Hold Alt (Windows) or Option (Mac), and click the Stopwatch icon next to the Start property to add an expression.
  4. Use the following expression:

    javascript
    Copy code
    delay = 0.05; // Basic delay between each character pauseForComma = 0.5; // Additional pause for comma (in seconds) txt = value; characters = text.sourceText.length; // Loop through the text and calculate the time based on commas t = time / delay; commas = 0; for (i = 0; i < t; i++) { if (i < characters && text.sourceText[i] == ',') { commas++; } } // Adjust time with comma pauses adjustedTime = time - (commas * pauseForComma); Math.min(adjustedTime / delay, 100);

How It Works:

  • The expression looks at each character in the text and adds a delay whenever it encounters a comma.
  • You can adjust the delay and pauseForComma variables to change the timing between regular characters and how long the pause for a comma lasts.

This will give you a natural typewriter effect with slight pauses after commas, simulating a realistic typing feel.

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
Explorer ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

delay = 0.05; // Basic delay between each character
pauseForComma = 0.5; // Additional pause for comma (in seconds)

txt = value;
characters = text.sourceText.length;

// Loop through the text and calculate the time based on commas
t = time / delay;
commas = 0;

for (i = 0; i < t; i++) {
if (i < characters && text.sourceText[i] == ',') {
commas++;
}
}

// Adjust time with comma pauses
adjustedTime = time - (commas * pauseForComma);
Math.min(adjustedTime / delay, 100);

 

here's the code so it's easier to copy/paste

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
LEGEND ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

This doesn't pause on the actual commas, it only lengthens the overall time, so I'm not sure what you are suggesting here.

 

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
Enthusiast ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

Try this:

delay = 0.25
pauseForComma = 0.5
txt = value
characters = txt.length
t = time
displayTime = 0
visibleCharacters = 0
for (i = 0; i < characters; i++) {
  visibleCharacters++

  displayTime += delay

  if (txt.charAt(i) == ",") {
    displayTime += pauseForComma
  }

  if (t < displayTime) {
    break
  }
}
txt.substr(0, visibleCharacters)

csscms.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
Engaged ,
Sep 25, 2024 Sep 25, 2024

Copy link to clipboard

Copied

LATEST

Thank you! Very much appreciated, marked as correct answer. Cheers

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