How to create a text typewriter with a cursor in After Effects?
-
-
- Create a text layer.
- Add a Slider Control to the text layer and rename it to Text.
- Add a Checkbox Control to the text layer and rename it to On/Off.
- Alt-click on the Source Text property and paste the expression below.
var sign = "|"; // change the blinking sign to "▌"or "_" var blinkInterval = 15; // edit the blinking interval in frames // slider with text length var i = effect("Text")("ADBE Slider Control-0001"); // checkbox to turn the cursor on and off var on = effect("On/Off")("ADBE Checkbox Control-0001"); var frames = timeToFrames(time); var check = frames / blinkInterval; if (on == 1) { if (i.valueAtTime(time + thisComp.frameDuration) > i) { end = sign; } else { if (Math.floor(check) % 2 == 0) { end = sign; } else { end = " "; } } } else { end = " "; } text.sourceText.substr(0,parseInt(i)) + end;
- Turn on the On/Off checkbox.
How does it work?
Animate Text slider (a 1st keyframe must have 0 value, a 2nd keyframe – your text’s length or bigger value).
Animate On/Off checkbox to start or stop the blinking cursor.
Adjust blinking speed by changing the blinkInterval variable value in the expression (the lesser the value the faster is the blinking).
You can also change the blinking sign by replacing the sign variable.
How to erase text?
Animate Text slider backward.
How to make cursor to blink once the type out animation has finished?
Animate the On/Off checkbox (a 1st keyframe will be 1, a 2nd keyframe will be 0).
How to change the cursor’s color?
-
- Press Animate – Fill Color – RGB.
- Expand Range Selector 1.
- Alt-click on the Start property and paste an expression below.
string = text.sourceText; counter = 1; for (var i = 0; i < string.length; i++) { if (string[i] == "r") counter++; } text.animator("ADBE Text Animator")("ADBE Text Selectors")("ADBE Text Selector")("ADBE Text Index End") - counter;
-
- Alt-click on the End property and paste an expression below.
text("ADBE Text Document").length;
- Expand Advanced property and change Units to Index
-
Hope you enjoyed this tutorial on how to create a type on text preset. Leave a comment if you have any questions.
Update. In case you need the cursor to blink at the same speed ignoring the typing use this expression instead:
var sign = "|"; // change the blinking sign to "¦"or "_" var blinkInterval = 15; // edit the blinking interval in frames // slider with text length var i = effect("Text")("ADBE Slider Control-0001"); // checkbox to turn the cursor on and off var on = effect("On/Off")("ADBE Checkbox Control-0001"); var frames = timeToFrames(time); var check = frames / blinkInterval; if (on == 1) { if (Math.floor(check) % 2 == 0) { end = sign; } else { end = " "; } } else { end = " "; } text.sourceText.substr(0,parseInt(i)) + end;