Problem with smoothing out speech bubble dialogue flow

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
scratchyback
Posts: 8
Joined: Sun Apr 05, 2015 12:28 pm

Problem with smoothing out speech bubble dialogue flow

Post by scratchyback »

Hello,







I have created a 2D speech bubble-line Dialogue system where the user can pick the responses from a panel (the clicked response (the reminder) is then shown  above the player's head). There are parts in the dialogue where there is just one response so the Player and NPC start talking on their own for a bit (the response panel is not shown, I set 'Always force response menu' to false)







However, when the dialogue starts with the subtitle of the NPC (above their head), there is a delay before the response panel is shown. I think this is because of the setting : 'Min Subtitle seconds'. If i change this from the default 2 to 0, the response panel pops up much quicker. But then the subtitles (plus reminder line of the player) are shown too short.







I do not want to implement continue buttons for all reminder lines just to solve this. I want the dialogue to feel natural and not be a burden for the users with too many clicks. What I would like is something like this:



- When the dialogue starts the NPC line is shown as well as the response panel, simultaneously.



-When the player clicks a response in the panel, the player reminder is shown in the speech bubble  for about 2-3 seconds, before moving on to the next NPC line. (there is no continue button)



- When there is just one option for the Player and the dialogue continues by itself, the NPc line is shown. It stays in place and doesnt disappear just yet.



- 2-3 seconds later the player response appears in the speech bubble. The player response now has a continue button. As long as the button isnt pressed, both the NPC line as the (auto) response of the player stay on the screen.



- When the continue button is pressed, the next NPC line appears in the speech bubble.



This is to accomplish that when the NPC and player start to talk without any choices in between., the user has enough time to read them, but doesnt have to click on a button for both the NPC as the player.







I hope I explained this all properly. Can this be done? And if it cant be done by setting properties in a clever way, can you point me the way to where I need to script this and how to best go about this?







Really hope you can help.
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Problem with smoothing out speech bubble dialogue flow

Post by Tony Li »

Hi,



To control whether to wait or progress immediately, you'll use sequences. The conversation stays on a dialogue entry for the duration of its sequence.



4309 wrote: When the dialogue starts the NPC line is shown as well as the response panel, simultaneously.


Set the NPC line's Sequence field to:

None()

This will immediately progress the conversation to the next stage, which is the response panel.







4309 wrote: When the player clicks a response in the panel, the player reminder is shown in the speech bubble for about 2-3 seconds, before moving on to the next NPC line.


Set the player response dialogue entry's Sequence field to:

Delay({{end}})





This will delay for a duration based on the length of the dialogue text. To adjust the speed, adjust Subtitle Chars Per Second and/or Min Subtitle Seconds.







4309 wrote: When there is just one option for the Player and the dialogue continues by itself, the NPc line is shown. It stays in place and doesnt disappear just yet.


Set the NPC dialogue entry's Sequence to:

Delay({{end}})

If you find that you're using one of these sequences more often than the others, set it as the Dialogue Manager's Default Sequence. Then you can just leave those dialogue entries' Sequence fields blank. When a dialogue entry's Sequence field is blank, it uses the Dialogue Manager's Default Sequence.







4309 wrote: 2-3 seconds later the player response appears in the speech bubble. The player response now has a continue button. As long as the button isnt pressed, both the NPC line as the (auto) response of the player stay on the screen.


Set the Dialogue Manager's Continue Button setting to Not Before Response Menu. This means the continue button will always appear if the next stage is a line (player or NPC), but never if the next stage is a response menu.



If you want to keep the PC and NPC lines on the screen at the same time, it requires a tiny bit of scripting. Identify the dialogue UI script for the GUI system you're using -- for example, UnityDialogueUI for legacy Unity GUI (which is what the prefabs use), UnityUIDialogueUI for the new Unity UI, etc.



Create a subclass that overrides the HideSubtitle() method. For example, MyDialogueUI.cs:

using UnityEngine;

using PixelCrushers.DialogueSystem;

using PixelCrushers.DialogueSystem.UnityGUI;



public class MyDialogueUI : UnityDialogueUI {



public override void HideSubtitle(Subtitle subtitle) {

// Do nothing. Don't hide the subtitle.

}

}

Then drag this script into the Script field of your dialogue UI, replacing UnityDialogueUI You may want to play around with it a bit to get the behavior you want.



If you have any follow up questions, please ask. It's all fairly easily accomplished with little to no coding required. If I've misinterpreted some of your requirements, just let me know so we can get it working the way you want.


scratchyback
Posts: 8
Joined: Sun Apr 05, 2015 12:28 pm

Problem with smoothing out speech bubble dialogue flow

Post by scratchyback »

Wow, thank you for the extensive help. With your comments I have come a lot further. There are still two things that dont go as I want:





When the player clicks a response in the panel, the player reminder is shown in the speech bubble  for about 2-3 seconds, before moving on to the next NPC line. (there is no continue button)





I made the changes with the Delay({{end}}) sequence and I set the Continue button to 'Not Before Response Menu', but in this case the continue button is shown. I would like the Continue button to only show  in the player bubble when the player line is shown automatically because it was the only response available.

 When there is just one option for the Player and the dialogue continues by itself, the NPc line is shown. It stays in place and doesn't disappear just yet.





I have made the changes in the script as you suggested but it seems to be working the other way around. The PC bubble now stays on the screen when the next NPC line is shown. I would like it the other way around, so show the NPC line and then the following PC line both on screen.



I tried to change the script as follows but that didnt do the trick:



public override void HideSubtitle(Subtitle subtitle) {

// Only hide the subtitle when it is of the player, not when it is of the NPC

if (subtitle.speakerInfo.characterType == CharacterType.PC) {

base.HideSubtitle(subtitle);

}

}





(I tried to format my code as pretty as yours in this post, but alas...the forum editor doesn't like me)
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Problem with smoothing out speech bubble dialogue flow

Post by Tony Li »

Hi,



Sorry, this isn't the greatest forum software. The "< >" button on the toolbar lets you insert formatted code.



Try the dialogue UI below. You can also download it and an example scene here.  The key bit of code checks DialogueManager.CurrentConversationState, which (confusingly) is actually the previous line because the conversation isn't considered to have fully transitioned into the new line until after the subtitle has been shown.

using UnityEngine;

using System;

using System.Collections;

using PixelCrushers.DialogueSystem;

using PixelCrushers.DialogueSystem.UnityGUI;



public class TestDialogueUI : UnityDialogueUI {



public override void ShowSubtitle(Subtitle subtitle) {

DialogueManager.DisplaySettings.subtitleSettings.continueButton =

((DialogueManager.CurrentConversationState != null) &&

DialogueManager.CurrentConversationState.HasPCAutoResponse)

? DisplaySettings.SubtitleSettings.ContinueButtonMode.Always

: DisplaySettings.SubtitleSettings.ContinueButtonMode.Never;

base.ShowSubtitle(subtitle);

}



public override void HideSubtitle(Subtitle subtitle) {

if ((DialogueManager.CurrentConversationState != null) &&

DialogueManager.CurrentConversationState.HasPCAutoResponse) return;

base.HideSubtitle(subtitle);

}



}
scratchyback
Posts: 8
Joined: Sun Apr 05, 2015 12:28 pm

Problem with smoothing out speech bubble dialogue flow

Post by scratchyback »

Wow (again), thanks for the amount of work you put into this reply. Really, hats up, the support on this forum alone is already more than worth the investment in your amazing dialogue system.







I have inserted your code. The continue button now works as a charm, only showing up in case when it is an autoresponse.



The only weird thing I still have, is that the NPC subtitle still disappears even though the code in the HideSubtitle seems to be executing properly when I step through it with the debugger.



It goes to the 'return' in the if-statement as expected, but still the Subtitle disappears.



I compared to your project (which doesn't have this issue and works perfect), the differences is that mine is not a GUI interface but the new UI on World Space instead of overlay (so my class derives from UnityUIDialogueUI).



I also debugged through yours and checked my sequences, but it all seems to be the same.....
scratchyback
Posts: 8
Joined: Sun Apr 05, 2015 12:28 pm

Problem with smoothing out speech bubble dialogue flow

Post by scratchyback »

I did more 'spot the differences' between your project and mine because I couldn't stand it that I couldn't figure this out, and i found the difference!







In my dialogue I set the 'NPC reminder' line to the same UI element as 'NPC line' because I figured that would save me creating the same UI elements twice. But that turned out to be the cause of my problem.



I now created a separate 'Reminder line' and it works absolutely perfect now. So thanks again for your support and help!
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Problem with smoothing out speech bubble dialogue flow

Post by Tony Li »

Happy to help, and glad it's all working now!
Post Reply