Page 1 of 1

Changing the Typewritter Effect's Speed Mid Sentence

Posted: Thu Apr 28, 2016 9:39 am
by Saruto
First, I just wanted to express how much I appreciate everything you guys have done for us. It's seldom that I see both quick and effective technical support, so thank you!

I was working on creating more lively conversations in my game. Because there's no voice acting, I'm going to have various effects on the displayed subtitle text in order to express the character's emotions. I am using a slightly modified version of the UnityUITypewriterEffect script that came with the system, and I wanted to simulate natural conversational flow by altering the charactersPerSecond field while the characters are talking. For example, I was going to emulate a short mid-sentence pause in speech by setting the charactersPerSecond to zero after a certain point in the sentence, and then set it back to its default value after a certain amount of time. I would do this in a custom C# function that's been placed in the Lua environment.

However, when I tested this out, it did not work. Looking at the script, it looks like it's because the charactersPerSecond field is used to calculate the speed only once at the start of the Play() function. Because of this, changing the field mid-play would not have any effect. In addition, the function appears to reject nonpositive charactersPerSecond values, so I would not be able to do the above example (though, setting it to a very small positive value seems like a possible workaround).

Is there any other way I can get the effect I'm looking for? Editing the code to get the desired effect seems somewhat non-trivial from what I can tell, and I don't want to make any huge edits without a deep understanding of the system. I suppose I could automatically call OnContinue after a certain amount of time, but I don't want the text box to erase itself after doing so.

Thanks for your time!

Re: Changing the Typewritter Effect's Speed Mid Sentence

Posted: Thu Apr 28, 2016 10:59 am
by Tony Li
Hi,

Thanks! I'm glad the Dialogue System's working out for your project!

If you're using the typewriter effect in v1.5.9+, you can use RPGMaker-style pause codes in your dialogue text. How about using them instead of changing the characters per second?
  • \, -- Quarter pause (default 0.25s)
  • \. -- Full pause (default 1.0s)
  • \> -- Following text appears instantly
  • \< -- End of instant text; resume typewriter effect
  • \^ -- Skip to the end
If possible, use the latest version of the typewriter effect, since it also includes performance improvements and minor bug fixes.

Re: Changing the Typewritter Effect's Speed Mid Sentence

Posted: Thu Apr 28, 2016 12:43 pm
by Saruto
Oh, awesome! It's been a little while since I've checked for updates, so sorry about that.
It looks like it works great! So thanks again!

I also just wanted to mention the "slight modifications" I mentioned in my last post. I added functionality onto the script that varies the volume and pitch of the audio clip every time it plays, while also allowing you to control the min and max values of the variation. For most situations the range for both will be small, but it gives subtle variation to the clip so that it doesn't become too grating to listen to. Setting a large pitch range also makes for a crazy sounding effect, which is especially useful for representing super erratic characters.

It's not the coolest modification ever, but I'd figure I'd suggest it since I mentioned it earlier.

Thanks, and have a good day!

Re: Changing the Typewritter Effect's Speed Mid Sentence

Posted: Thu Apr 28, 2016 12:46 pm
by Tony Li
Good idea! I'll keep that variation in mind, or at least a similar variation where the effect can play randomly from a list of audio clips. I've had a request for that, too.