Add pauses to text box typewriter effect?

Hi, I made this text box widget which has a simple typewriter effect, but it writes the text on screen at a constant speed. How could I make it have a small pause or delay between the two strings?

Here’s what I have so far:

You could add “Delay” variable, and set it to shorter or longer period.
So for end of sentence you set it to long, then AFTER every character “typed” you set it back to short
This way it is long only for new sentence.

Also I have feeling that your code can be made much simpler.

If you want have a random a delay between each character, you can do this:


If you want a longer pause between the sentences, you can just check if the character is a period, and if it is, use a longer delay.

Example

1 Like

thanks for replying.

so I ended up making this differently. Now it’s delay based and it has a longer delay time after periods, exclamation or question marks.

however I’m only half satisfied with this. I also wanted to be able to add a custom delay on a case-by-case basis, not dependent on any characters. So if I wanted to add say a 10 second delay in the middle of a word, I’d be able to.

ideas?

Yeah, you would just put a special ‘code’ in the text, and check for it when typing. For example, if the text is “Hello, this is $PAUSE 2 Bob,” then your blueprint would check for “$PAUSE”, and if it finds one, then it pauses for the specified number of seconds (in this case, 2). You could also do this a number of other ways, but that’s a quick way of doing it.

okay I thought of something like this, but how can I make it so the “$PAUSE” text won’t be displayed in my text box?

I love such small blueprint challenges, so do not mind me :wink:

typewriter_D

1 Like

If you’re appending each character to the textbox text, then you would just skip it and go to the next character. But if you’re revealing parts of the original string (like in my example), then you would just remove it from the original string before displaying it. There’s also Replace/Replace Inline which will replace all occurrences of one string with a another one (which you would leave blank to remove it).

I would not use $ as marker, you will have trouble with typing out dollars.
So something else, For eg #, and then number like #1.25 ie formatted to be same length, so you know after # there are 3 digits

Code would be not so complicated, when parsing string if you find marker # or $ you know next 3 characters are delay for this iteration, so you read them, change to float, and cut out of output string (or skip and do not add to output).

1 Like

Rright, # should work.

So I suppose the Replace function worked for getting rid of any “#” delay flags I add to my string, but how do I recognize it so I can have a branch to set up a specific delay?

Currently I’m using “Get Character Array from String” so I can use == to compare each individual character, and if it’s a “#” then I can set up a branch and use a multiplier for my delay time, but ideally I would have different words like #smalldelay or #bigdelay, but I’m not really sure how to recognize words within a string.

Better yet, I would have it recognize the numbers after the “#” so I could set up a specific delay multiplier within the string, as suggested, but I’m also not sure how to do so

Will you use this for widgets? Or any string? Because whole “tiny challenge in blueprints” is getting close to when it is easier to make project, pack it and share.

Yes! It’ll be used for a text box widget.

That last image I attached better illustrates what I currently have, it’s simple and I was trying to have my text as a single string instead of an array, as I’ll probably need a string array later on.

Hey guys, I think this post is awesome!

If you all don’t mind me pitching in:

Stopping to share a sort of idea in C++ for blueprint logic that executes and cleans commands from strings… something like: https://onlinegdb.com/Qeb7gZpHo

Ok, so I went with this idea:



So it just goes character by character, and if the next character is a “#”, it runs the following command. The “Do command” section is a little messy, but it just gets the command (by getting the string between the “#” and the next space), removes it from the original text (without removing all other commands), searches it in a map, and if it finds it, runs its delay.

Example

1 Like

If your commands are same character length, you can save yourself that search for ’ '.

if you want a bit more flexibility: you can also have numbers in your command that can be extracted for the delay.

EDIT: also… if you are able pass your commands to a switch node, you can execute events like waiting for input to continue, vfx, animations, etc. :nerd_face:

1 Like

Just slapped that in; it’s a simple modification:


Which allows you to optionally add an offset to the delay:
image

1 Like

Just one last thing lol → make it dependent on a Timer by Event with loop wile printing text… not with delay nodes. Should allow you to stop mid delay and does the exact same thing without the need to Tick.

1 Like

Lol that is cool little problem to code esp in spaghetti blueprints.
Took longer than i thought but here is my take on it:
numbers.7z (2.4 MB)

1 Like

This works just great! But since you added the option to check for the specified offsets to the delays, then I suppose I don’t really need the pre defined commands such as #smalldelay, #bigdelay etc? Would it be possible to simplify it for having commands such as #3 or #30 or even #1.57?

1 Like

Yeah, the “DoCommand” event changes to this:


This one takes numbers as #1.5# so you can put them inside words (since looking for spaces wouldn’t work in words):