Best Practices

Find all common best practices when using Text Animator for Godot.

Every project is different, but in this page you can find some common best practices that can help you set up everything better and avoid most common issues!

Use Both RichTextLabel and Typetriter to show text

If you're setting text via code, the Godot version uses the following methods:

  • SetText() from RichTextLabel: Shows the entire formatted text at once.

  • ShowText() from Typewriter: Displays the formatted text progressively as a typewriter.


Set the entire text/dialogue only once

Please try to set text just once, and use the typewriter / visibility methods to control how it appears.

Example

If you have a character that says "Helloooo how are you doing?", and you want to display it letter by letter, simply set it once like typewriter.ShowText("Hellooooo how are you doing?"); and then play with the typewriter, instead of setting a new text (with extra letters in _process! Show and hide letters dynamically


If you're building a dynamic string, you can still do that before setting its value to the typewriter/animator.


int apples = 5; //later taken from the game state
string playerName = "Bob";

// build the entire dialogue line first
string dialogue = $"Hello {playerName}, you've got {apples} apples";

// then set the text once
typewriter.ShowText(dialogue);
Why should I set the entire text once, instead of character by character?

Performance! (Even if you didn't have Text Animator.)

Every time you set the text, RichTextLabel needs to calucalte each character position, size, built-in animations if BBCodes are enabled, etc... and Text Animator has then to re-calculate character durations and more. This means that if you change it multiple times per second (e.g. adding more letters), you're doing these calculations every time.

To display characters one by one, you can simply set the full text once, and then start the typewriter: Show and hide letters dynamically