TypewriterEffect plays SFX 2x faster than text

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
pikcelery
Posts: 2
Joined: Tue Dec 05, 2023 3:54 pm

TypewriterEffect plays SFX 2x faster than text

Post 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?
pikcelery
Posts: 2
Joined: Tue Dec 05, 2023 3:54 pm

Re: TypewriterEffect plays SFX 2x faster than text

Post 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!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: TypewriterEffect plays SFX 2x faster than text

Post 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.
Post Reply