Hey,
I'm using the dialogue system with talking animations. I've set it up so onConversationLine it will play a looped talking animation and stop onConversationLineEnd and onConversationLineCancelled. The issue I'm having is that the character will keep talking after all the text is being presented - I only want the animation to work during the Typewriter Effect (Text showing overtime).
The method I'm trying to do is grabbing the DialogueManager.displaySettings.subtitleSettings.subtitleCharsPerSecond and trying the grab the text that is going to show (currently cannot figure that out). Using these values, I will calculate the time it takes to show the text and stop talking animation.
Thank you to anyone that can help me!
How to: Calculate duration of the Typewriter Effect
Re: How to: Calculate duration of the Typewriter Effect
Hi,
When the typewriter effect is done, it sends the message "Typed" to the sequencer. Your sequences can listen for this message, such as:
The sequence immediately above plays the "Talk" animator state on the speaker.
Then it waits for the message "Typed", which will be sent by the typewriter. When it receives the message, it plays the "Idle" animator state. The "required" keyword guarantees that it runs this sequencer command even if the conversation skips ahead before the typewriter is finished.
---
To answer your question (which you probably no longer need at this point), there's a different between the Dialogue Manager's Subtitle Settings > Subtitle Chars Per Second and the typewriter effect's Characters Per Second. The Dialogue Manager's Subtitle Chars Per Second is used to compute the value of the special sequencer keyword "{{end}}". It doesn't affect the typewriter.
Say your text is 120 characters long. If the typewriter effect's Characters Per Second is 60, then it will take 2 seconds (120 / 60) to type out.
If the Dialogue Manager's Subtitle Chars Per Second is 40, then the value of {{end}} will be 3 seconds (120 / 40). So if your sequence is:
Then the typewriter will finish after 2 seconds, and the node will delay for an additional second (total of 3 seconds) before continuing. If you're enabled continue button mode, of course, it won't actually continue at this point until the player clicks the continue button.
To get the typewriter's Characters Per Second value, you'd need to get a reference to it, and use its charactersPerSecond value. To get the text, you'll typically add an OnConversationLine(Subtitle) method to a script and check subtitle.formattedText.text.Length. Outside of OnConversationLine, you can check DialogueManager.currentConversationState.subtitle.formattedText.text.Length.
When the typewriter effect is done, it sends the message "Typed" to the sequencer. Your sequences can listen for this message, such as:
Code: Select all
AnimatorPlay(Talk);
required AnimatorPlay(Idle)@Message(Typed)
Then it waits for the message "Typed", which will be sent by the typewriter. When it receives the message, it plays the "Idle" animator state. The "required" keyword guarantees that it runs this sequencer command even if the conversation skips ahead before the typewriter is finished.
---
To answer your question (which you probably no longer need at this point), there's a different between the Dialogue Manager's Subtitle Settings > Subtitle Chars Per Second and the typewriter effect's Characters Per Second. The Dialogue Manager's Subtitle Chars Per Second is used to compute the value of the special sequencer keyword "{{end}}". It doesn't affect the typewriter.
Say your text is 120 characters long. If the typewriter effect's Characters Per Second is 60, then it will take 2 seconds (120 / 60) to type out.
If the Dialogue Manager's Subtitle Chars Per Second is 40, then the value of {{end}} will be 3 seconds (120 / 40). So if your sequence is:
Code: Select all
Delay({{end}})
To get the typewriter's Characters Per Second value, you'd need to get a reference to it, and use its charactersPerSecond value. To get the text, you'll typically add an OnConversationLine(Subtitle) method to a script and check subtitle.formattedText.text.Length. Outside of OnConversationLine, you can check DialogueManager.currentConversationState.subtitle.formattedText.text.Length.
Re: How to: Calculate duration of the Typewriter Effect
Hey,
Thank you for replying to me!
I managed to create a script that inherits 'Standard Dialogue UI" and created a public function that links UnityUITypewriterEffect from the NPC's Subtitle Text. From there, I can grab charactersPerSecond plus use it's events (OnBegin, OnEnd) to turn on and off my Talking animations. I'm not sure if there's a cleaner way to this but it works nicely for now.
I am struggling to understand how to use Sequences and use it in C# format - mainly for my own functions so I can play face expressions. I assume AnimatorPlay(Talk) is code for grabbing the speaker's Animator component and playing the 'Talk' animation? If that's the case, it may not work with what I'm using - which is Spine animations and it doesn't use Unity's Animator.
But anyway, the talking animations are working nicely!
Thanks again for your help!
Thank you for replying to me!
I managed to create a script that inherits 'Standard Dialogue UI" and created a public function that links UnityUITypewriterEffect from the NPC's Subtitle Text. From there, I can grab charactersPerSecond plus use it's events (OnBegin, OnEnd) to turn on and off my Talking animations. I'm not sure if there's a cleaner way to this but it works nicely for now.
I am struggling to understand how to use Sequences and use it in C# format - mainly for my own functions so I can play face expressions. I assume AnimatorPlay(Talk) is code for grabbing the speaker's Animator component and playing the 'Talk' animation? If that's the case, it may not work with what I'm using - which is Spine animations and it doesn't use Unity's Animator.
But anyway, the talking animations are working nicely!
Thanks again for your help!
Re: How to: Calculate duration of the Typewriter Effect
Hi,
The Dialogue System has Spine integration. You can use the SpineAnimation() sequencer command to play Spine animations.
The Dialogue System has Spine integration. You can use the SpineAnimation() sequencer command to play Spine animations.
Re: How to: Calculate duration of the Typewriter Effect
Sorry for the late reply but thank you for your help!
Re: How to: Calculate duration of the Typewriter Effect
Glad I could help!