I have a text system using a richtextlabel that loops, increasing the visible characters from 0 to the maximum until the entire text is displayed. I have made is possible so that characters such as “.” and “,” add a small delay, but I want to add a character that adds a delay without being visible. I assume this would be done with bbcode, but visible characters and ratio ignore bbcode so I don’t know how to accomplish this. Any help would be great to as what character I could use, or even get it to detect bbcode.
Hi,
BBCode should be used to format text, not for that kind of stuff, imho.
One way you could achieve that is, each time you increase the number of visible characters, loop through the characters that have just been revealed (with a loop going from the previous visible characters count to the current one). If during that loop, you encounter a special character, you can trigger any special behaviour.
There may be an issue with some characters after the special one being visible. For instance, if the characters that have been displayed are hello. world
, you want the letters after the dot to be hidden, since the delay is applied on that dot. To fix that, simply decrease the visible characters count so that the last visible one is the special one.
Let me add that, using characters such as dot or commas for that kind of stuff may be a problem, as you may not always want those characters to have a special behaviour. Even worse, you may sometimes want a dot with a delay and another without a delay, in the same sentence, which would make it very hard to distinguish.
You could try implementing another system, such as custom tags inside your sentences, like [delay]
. That would require to parse the text and do some stuff with the custom tags before displaying it, but that would make the whole system more safe and easy to iterate on.
I hope that makes sense. Anyway, I just wanted to let you know that your solution could come with this kind of problems, but, I know you’re a Godot beginner, so go for the solution you find the easier to implement and that you understand the better
I had no idea that you could make custom tags. I’ll have to look into that for sure. Thank you
Custom tags like this are a cool way of making good use of string tools. Since they’re not part of the engine but a hand made feature, you can format them any want you want.
For instance, you could have:
Hello [delay] world
Hello /delay world
Hello [delay 2] world
The latter having a parameter to control the delay duration.
As long as you’re able to parse your initial string to usable data in your code, you can do pretty much anything you want with strings.
Another cool thing is, since strings exist outside Godot, you could reuse your custom logic in any other game engine. I know you’re not there yet, but that’s always good to note!