Page 1 of 1

TypewriterEffect plays SFX 2x faster than text

Posted: Tue Dec 05, 2023 4:21 pm
by pikcelery
Hi, I'm trying to use TypewriterEffect to play SFX alongside my text. My audio clip is pretty long (6s) but I'm using "Use Play One Shot" and "Interrupt Audio Clip" as I'm trying to play the SFX once for each character.

I'm experiencing an issue where the audio clip is played at roughly 2x the speed that the characters appear. This results in the audio finishing playback when only half the characters are on the screen. From my testing the typewriter effect itself seems to match the "Characters Per Second" value but the SFX is being played too fast.

Here's how my typewriter is configured:

Image

I'm digging into the code to debug this, but just wanted to ask if you've seen this issue before? Maybe it's a configuration issue on my end?

Re: TypewriterEffect plays SFX 2x faster than text

Posted: Tue Dec 05, 2023 5:48 pm
by pikcelery
The code in

Code: Select all

AbstractTypewriterEffect
and

Code: Select all

UnityUITypewriterEffect 
appear to be working as intended, calling PlayCharacterAudio() once as each character is displayed.

The issue seems to go away if I disable "Use Play One Shot", so problem solved. I suspect PlayOneShot() might be behaving strangely because of the high rate of calls.

Appreciate the work you do on this asset!

Re: TypewriterEffect plays SFX 2x faster than text

Posted: Wed Dec 06, 2023 9:00 am
by Tony Li
You're correct. Play One Shot doesn't work with Interrupt Audio Clip. When you play a one-shot, it spins off an entirely separate process for the audio clip that's no longer controlled by the typewriter, so the typewriter can't interrupt it.