Typewriter effect for formatted rich text box

I’ve been searching for a good method of creating a letter by letter typewriter affect for dialogue boxes. I’ve found a few different methods but none seem to really work for me.

I want to know if anyone knows of a good tutorial or has a screenshot of a letter by letter function for rich text boxes that will properly print each letter of formatted words instead of printing the formatting syntax and the string then formatting it on completion.

Thank you for your help!

For a typewriter effect, you can use a FunctionTimer to display character per character > append to a string > display in textbox.

To work with RichText, you will need to do some string manipulation by detecting an open < and end tag /> and just append them at one go to the string. for a word it fine but for a whole phrase inside a tag it will lose that typewriter effect.
In a dialogue usually we usually emphasis one single word anyway.

Its all good, I was able to make the function myself.

For anyone who may come across this post trying to do something similar to what I was, this is for you.

This function takes the input of a source string, then it adds each letter to the ui textbox one by one until it recognizes that a format flag is coming up, the format flag being “<”. Then it gets the name of the format (beware that if there is a lone “<” in your string this code will result in an infinite loop while it tries to find the ending flag “>”). Then it will stop typing formatted text when it finds the format flag “<” again, and resume typing text the normal way.

This should work for any string input, as well as any stylesheet formatting. The only drawbacks are that the last character inside the formatting isn’t formatted, but this can be worked around by adding whitespace right before the end of the format string. If you start your string with formatting, put a white space in front like " <"

The way the code functions, it will only run once so you will either need a for loop or a timer by function connected to the execution cable next to the source string in image one. I use a timer by function which is what the “On Dialogue End” portion is related to but you can use whatever method you see fit to trigger the end dialogue if you even need it. A while loop is what I recommend because I already created a Boolean variable that triggers the end of the loop, so not much new code would have to be added for that implementation.

Also, to add text to my rich text box I get the variable for my text box, drag off, and use the “Set Text” under content.
image

If this helped you out or you know of a better way to implement this feature I’d love to hear about it!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.