Hello there I'm currently making a small game, and I'd like to add dialog sounds when a character is talking, like shown in this video [

The big problem... I'm using a Dialog tool in Godot which is currently handled by a Tween setting the "percent_visible" of a RichTextLabel from 0 to 1. That has a bid downside! The text is being written in 1 second or so, meaning long text gets written really fast, and slow text really slow. I tried to smooth it out abit by declaring a new variable called "duration" with is 1. Its then checking how long the total number of characters there are in a sentence. Depending on the number of characters, the value drops or increases. Like this:

<pre class="prettyprint">
var duration = 1
if _Body_Label.bbcode_text.length() <= 5:
	duration = 0.25
elif _Body_Label.bbcode_text.length() <= 15:
	duration = 0.5
elif _Body_Label.bbcode_text.length() <= 30:
	duration = 0.75
elif _Body_Label.bbcode_text.length() <= 50:
	duration = 1
elif _Body_Label.bbcode_text.length() <= 100:
	duration = 1.5
$Tween.interpolate_property(
	Body_Label, "percent_visible", 0, 1, duration,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT
)
$Tween.start()

</pre>

This is a lazy solution for the problem, but it throws in more problems. For example handeling the timing of the dialog sound. I also looked into using a timer instead of a tween, but it didn't really work as intended, and since I'm not the best programer I afraid, I'm not able to fix it on my own ._.

If you happen to know what I could do, then I would be hella thankful!! Since I really do not know how to solve this... Thank you in advance!

P.S. Ignore the < pre class="prettyprint"> its just to format the code correctly in this thread

Well the dialog sound doesn't necessarily have to match exactly for each characters drawn (and maybe you don't want this depending on the speed of the text). You could just start the sound playing (maybe with a timer) that plays the sound and then checks "percent_visible" on the label and if it is close to full, then stop.

How are you storing the dialog sound? Is it one click at a time, or is it a longer loop? I would suggest making a sound that is a few seconds long and loopable (you can do this in Audacity, for example). Then start the sound playing (with loop) when you start the text animation and then set a timer with the same duration, on the finished signal then stop playing the sound. That should work okay.

Thanks for your fast answer! I have a single sound which I'm gonna try to loop. But I'll try setting up a timer. And perhaps change the playback speed of the sound depending on how fast its being written? Hope I can find a solution :D

2 years later