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
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)
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
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.
Apply the "Typewriter" preset to your text layer:
Open the Range Selector 1:
Add an expression to the Start property:
Use the following expression:
This will give you a natural typewriter effect with slight pauses after commas, simulating a realistic typing feel.
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
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
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)
Copy link to clipboard
Copied
Thank you! Very much appreciated, marked as correct answer. Cheers