Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Can I dynamically change the readDelay from a script while displaying text?

A topic by yhiroki created May 06, 2024 Views: 96 Replies: 1
Viewing posts 1 to 2

I would like to create an effect where the interval between displaying characters slows down as more characters are displayed. (For example, like a person leaving their last words on their deathbed!)

I have tried the following code, but there is no change in the character display interval and it is not working as expected.

// Calculate to increase up to five times the normal interval when the maximum number of characters is reached
float maxDelay = _textDispInterval * 5;
float currentDelay = _textDispInterval + (_currentShowCharacterCount / (float)stm.Text.Length) * (maxDelay - _textDispInterval);
stm.readDelay = currentDelay

Is there a way to achieve such an effect?

Developer (1 edit)

Hello!


The way this is meant to be implemented is with inline tags!

<readDelay=x> will change the read delay value mid-string, so this is probably what would be most helpful. Use </readDelay> to return the delay back to a default value.

<d=x> will insert a single multiplier to the read delay (eg. if your delay is 0.1, typing <d=7> will produce a 1-time delay of 0.7) You can also define preset delays in the text data editor (the [T] icon in the top-right of any STM component) so if you're using the same delay over and over again, you can define it there so you don't have to edit your entire game script to make a programming value change.

The tags let you do a lot of mid-string programming, so I hope they're useful in this situation!