Assistance Request

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Asaku
Posts: 5
Joined: Tue Feb 13, 2018 5:15 pm

Assistance Request

Post by Asaku »

Hello everyone. I'm sorry if most of these will seem trivial but I've just purchased the dialogue system asset and it's a bit more complicated than what I have anticipated. I would like to kindly ask someone to point me in the right direction in regard to the following:

Image

Also, every dialogue, at least as of now, doesn't involve any options from the player. It's all between NPCs.

I have read the documentation but I do not see a straightforward way of implementing everything with my current understanding of the asset.

Thanks in advance.
User avatar
Tony Li
Posts: 22061
Joined: Thu Jul 18, 2013 1:27 pm

Re: Assistance Request

Post by Tony Li »

Hi,

Thanks for buying the Dialogue System!

Here's an example scene: AsakuExample_2018-02-13.unitypackage

I'll try to answer each question below by describing how I set it up in the example scene.
Asaku wrote: Tue Feb 13, 2018 5:38 pmActor preview: portrait
First I set up the dialogue UI:
  • I started with the JRPG2 prefab dialogue UI, which I added to Dialogue Manager > Canvas.
  • I inspected its Dialogue Panel GameObject and set Canvas Group to 1 to make it visible.
  • Then I added another portrait image to the dialogue UI. I named the original one "Portrait Image 1" and moved it to the left. I named the second one "Portrait Image 2".
  • Finally, I inspected the dialogue UI (Unity UI Dialogue UI component) and ticked Find Actor Overrides near the bottom of the inspector.
Next, I configured the second NPC to use Portrait Image 2:
  • I added two NPC GameObjects named "NPC1" and "NPC2".
  • On NPC2, I added an Override Unity UI Dialogue Controls. I assigned the regular dialogue controls (Subtitle Line, etc), except I assigned "Portrait Image 2" to the Portrait Image field.
When NPC2 is involved in a conversation, it will show its portrait image in Portrait Image 2.

I didn't add any transition effects yet. I was afraid it might be overwhelming in the example scene. We can cover that later. It's also configured right now to alternate portraits so you know who's talking.
Asaku wrote: Tue Feb 13, 2018 5:38 pmConfigurable type speed
The "Subtitle Line" GameObject has a component named Unity UI Typewriter Effect. This component's Characters Per Second field controls the type speed. I set up a UI panel in the upper right of the screen that controls this field with a slider.
Asaku wrote: Tue Feb 13, 2018 5:38 pmHighlighted keywords
To highlight words, wrap them in [em#] markup tags. For example, NPC2 says this: "Hello. I'm NPC 2. I'm saying more than NPC 1 to give the [em1]typewriter effect[/em1] more text to type." You can define the appearance of [em1] through [em4] in the Dialogue Editor window on the Database tab.

If you don't want to use [em#] tags, you can use rich text codes. For example: "There is a <b>keyword</b> in this text."
Asaku wrote: Tue Feb 13, 2018 5:38 pmText color based on actor
I downloaded the Actor Subtitle Color script from the Dialogue System Extras page and added it to NPC2. Then I set the color to magenta. (You don't need to download the script; it's included in the example.)
Asaku wrote: Tue Feb 13, 2018 5:38 pmAlways wait for user input before next dialogue
I inspected the Dialogue Manager and set Display Settings > Subtitle Settings > Continue Button to Always.
Asaku wrote: Tue Feb 13, 2018 5:38 pmAudio while writing (typing)
I assigned an audio clip to the Unity UI Typewriter Effect's Audio Clip field.
Asaku wrote: Tue Feb 13, 2018 5:38 pmKeys for stopping audio and instantly completing sentence
This is built into the continue button, which uses a script named Unity UI Continue Button Fast Forward.
Asaku wrote: Tue Feb 13, 2018 5:38 pmMove ortho camera during dialogue
I used a sequencer command called Zoom2D(). Sequencer commands let you do all kinds of things in the game, such as playing audio or animations, controlling the camera, activating and deactivating GameObjects, even loading new scenes.
Asaku wrote: Tue Feb 13, 2018 5:38 pmStart dialogue from script
I added a button to the UI panel in the upper right and connected it to a small script that calls DialogueManager.StartConversation(). There are many other ways to start conversations, too.


EDIT: I also added a Dialogue System Events component to the Dialogue Manager. I configured its OnConversationStart and OnConversationEnd events to hide and show the UI panel in the upper right during conversations.
User avatar
Asaku
Posts: 5
Joined: Tue Feb 13, 2018 5:15 pm

Re: Assistance Request

Post by Asaku »

Tony Li wrote: Tue Feb 13, 2018 8:41 pm Hi,

Thanks for buying the Dialogue System!

Here's an example scene: AsakuExample_2018-02-13.unitypackage
Thank you for taking the time to make one!
Tony Li wrote: Tue Feb 13, 2018 8:41 pm I'll try to answer each question below by describing how I set it up in the example scene.
Asaku wrote: Tue Feb 13, 2018 5:38 pmActor preview: portrait
First I set up the dialogue UI:
  • I started with the JRPG2 prefab dialogue UI, which I added to Dialogue Manager > Canvas.
  • I inspected its Dialogue Panel GameObject and set Canvas Group to 1 to make it visible.
  • Then I added another portrait image to the dialogue UI. I named the original one "Portrait Image 1" and moved it to the left. I named the second one "Portrait Image 2".
  • Finally, I inspected the dialogue UI (Unity UI Dialogue UI component) and ticked Find Actor Overrides near the bottom of the inspector.
Next, I configured the second NPC to use Portrait Image 2:
  • I added two NPC GameObjects named "NPC1" and "NPC2".
  • On NPC2, I added an Override Unity UI Dialogue Controls. I assigned the regular dialogue controls (Subtitle Line, etc), except I assigned "Portrait Image 2" to the Portrait Image field.
When NPC2 is involved in a conversation, it will show its portrait image in Portrait Image 2.
I have done as you described but unfortunately I wasn't able to replicate the scene behavior. The subtitles do indeed change but the NPC name and Portrait don't.
Tony Li wrote: Tue Feb 13, 2018 8:41 pm I didn't add any transition effects yet. I was afraid it might be overwhelming in the example scene. We can cover that later. It's also configured right now to alternate portraits so you know who's talking.
Looking forward to it!
Tony Li wrote: Tue Feb 13, 2018 8:41 pm
Asaku wrote: Tue Feb 13, 2018 5:38 pmText color based on actor
I downloaded the Actor Subtitle Color script from the Dialogue System Extras page and added it to NPC2. Then I set the color to magenta. (You don't need to download the script; it's included in the example.)
This does not seem to always work. When I have an [em1] tag for example it ignores it.
Tony Li wrote: Tue Feb 13, 2018 8:41 pm
Asaku wrote: Tue Feb 13, 2018 5:38 pmAudio while writing (typing)
I assigned an audio clip to the Unity UI Typewriter Effect's Audio Clip field.
Oh, I see! To be honest I didn't think about this. I was more thinking about actual voice acting over the writing. But this is pretty useful too!
Tony Li wrote: Tue Feb 13, 2018 8:41 pm
Asaku wrote: Tue Feb 13, 2018 5:38 pmMove ortho camera during dialogue
I used a sequencer command called Zoom2D(). Sequencer commands let you do all kinds of things in the game, such as playing audio or animations, controlling the camera, activating and deactivating GameObjects, even loading new scenes.
Neat! Gonna have to look more in depth into those.

Here is my attempt at replicating the example screen as indicated: https://drive.google.com/open?id=1u_cOX ... yO_EsYD3Ou

Again, thank you for your incredibly fast and complete response!
User avatar
Tony Li
Posts: 22061
Joined: Thu Jul 18, 2013 1:27 pm

Re: Assistance Request

Post by Tony Li »

Hi!

Please try this updated scene: AsakuExample_2018-02-14.unitypackage

It's MyTest / MyTestScene_edited_2018-02-14.
Asaku wrote: Wed Feb 14, 2018 4:10 pm I have done as you described but unfortunately I wasn't able to replicate the scene behavior. The subtitles do indeed change but the NPC name and Portrait don't.
This has to do with a sometimes confusing but useful feature of the Dialogue System that's detailed on this page: How GameObjects Are Associated With Conversations. When you start a conversation at runtime, you can assign any GameObjects as the conversation's actor and conversant, even if they're not associated with the conversation's primary actor and conversant defined in the database. This is handy to reuse generic conversations for multiple NPCs.

In your conversation, the primary actor was set to Player, and the primary conversant was set to NPC1:
  • Primary actor: Player
  • Primary conversant: NPC1
You may have noticed in your database that half of the lines looked like "Hello there kind sir", while the other half looked like "NPC2: Well hello there". This is because NPC2 was neither the primary actor nor the primary conversant, so NPC2 is treated like an additional, third participant.

To fix this, I clicked blank canvas space to inspect the conversation's properties. Then I changed the Actor dropdown from Player to NPC2. This means the conversation's primary actor is NPC2, and the primary conversant is NPC1.

Going back to the original issue, when the primary actor was set to Player, your button's "Start Conversation Script" called DialogueManager.StartConversation, passing NPC1 as the primary actor and NPC2 as the primary conversant. So at runtime the GameObjects being used were:
  • Primary actor: Player (in database) --> NPC1 (in the active conversation)
  • Primary conversant: NPC1 (in database) --> NPC2 (in the active conversation)
Anyway, to keep this from getting too long, the mismatch was the problem. By changing the conversation's primary actor to NPC2, the participants got connected to NPC actors. (They're actually swapped, where NPC1 ends up saying NPC2's lines and vice versa, but that's just a matter of swapping the assignments on the button.)

Asaku wrote: Wed Feb 14, 2018 4:10 pm This does not seem to always work. When I have an [em1] tag for example it ignores it.
I just updated the ActorSubtitleColor script. The previous version had a comment that it doesn't work with [em] or rich text codes, but better to just make it work with them. :-) The updated script is in the example package above, too.

For variety, in the very last line I used <i> (italics) tags instead of [em] tags.
Asaku wrote: Wed Feb 14, 2018 4:10 pm I was more thinking about actual voice acting over the writing.
I added an example to the scene. The third line uses the AudioWait() sequencer command. When you get into voice acting, you may be interested in the pages on entrytags and/or lipsync.
User avatar
Asaku
Posts: 5
Joined: Tue Feb 13, 2018 5:15 pm

Re: Assistance Request

Post by Asaku »

Tony Li wrote: Wed Feb 14, 2018 10:16 pm Hi!

Please try this updated scene: AsakuExample_2018-02-14.unitypackage

It's MyTest / MyTestScene_edited_2018-02-14.
Asaku wrote: Wed Feb 14, 2018 4:10 pm I have done as you described but unfortunately I wasn't able to replicate the scene behavior. The subtitles do indeed change but the NPC name and Portrait don't.
This has to do with a sometimes confusing but useful feature of the Dialogue System that's detailed on this page: How GameObjects Are Associated With Conversations. When you start a conversation at runtime, you can assign any GameObjects as the conversation's actor and conversant, even if they're not associated with the conversation's primary actor and conversant defined in the database. This is handy to reuse generic conversations for multiple NPCs.

In your conversation, the primary actor was set to Player, and the primary conversant was set to NPC1:
  • Primary actor: Player
  • Primary conversant: NPC1
You may have noticed in your database that half of the lines looked like "Hello there kind sir", while the other half looked like "NPC2: Well hello there". This is because NPC2 was neither the primary actor nor the primary conversant, so NPC2 is treated like an additional, third participant.

To fix this, I clicked blank canvas space to inspect the conversation's properties. Then I changed the Actor dropdown from Player to NPC2. This means the conversation's primary actor is NPC2, and the primary conversant is NPC1.

Going back to the original issue, when the primary actor was set to Player, your button's "Start Conversation Script" called DialogueManager.StartConversation, passing NPC1 as the primary actor and NPC2 as the primary conversant. So at runtime the GameObjects being used were:
  • Primary actor: Player (in database) --> NPC1 (in the active conversation)
  • Primary conversant: NPC1 (in database) --> NPC2 (in the active conversation)
Anyway, to keep this from getting too long, the mismatch was the problem. By changing the conversation's primary actor to NPC2, the participants got connected to NPC actors. (They're actually swapped, where NPC1 ends up saying NPC2's lines and vice versa, but that's just a matter of swapping the assignments on the button.)

Asaku wrote: Wed Feb 14, 2018 4:10 pm This does not seem to always work. When I have an [em1] tag for example it ignores it.
I just updated the ActorSubtitleColor script. The previous version had a comment that it doesn't work with [em] or rich text codes, but better to just make it work with them. :-) The updated script is in the example package above, too.

For variety, in the very last line I used <i> (italics) tags instead of [em] tags.
Asaku wrote: Wed Feb 14, 2018 4:10 pm I was more thinking about actual voice acting over the writing.
I added an example to the scene. The third line uses the AudioWait() sequencer command. When you get into voice acting, you may be interested in the pages on entrytags and/or lipsync.
Thank you so much for the explanation! Because of your introduction I'm able to understand much better the documentation. I will keep experimenting with the asset in the following days in order to get a better understanding of Lua commands for the sequencer.

I'll try to make a new scene in order to test that the behavior I need is all covered and later dig into the transition animations (unless you wish to make a quick example in which case I'm not saying no :D ). I'll keep using this thread for quick reference before I feel confident in fully relying on the documentation.
User avatar
Tony Li
Posts: 22061
Joined: Thu Jul 18, 2013 1:27 pm

Re: Assistance Request

Post by Tony Li »

Sounds good! If I can make time today, I'll add animation transitions to the example scene. Otherwise I'll update it tomorrow.

As you dig into the Dialogue System, keep in mind that there are two text-based command systems: Lua and sequences. They're different things. Lua is used mostly for data, such as checking and setting variables. You can enter Lua code in dialogue entry nodes' Conditions and Script fields. (These fields also have "..." buttons that provide dropdown menus so you don't have to type code manually.) Sequences, on the other hand, are used mostly for user experience activity, like playing audio, fading the screen, etc. You can extend both with your own custom Lua functions and sequencer commands if you want.
User avatar
Tony Li
Posts: 22061
Joined: Thu Jul 18, 2013 1:27 pm

Re: Assistance Request

Post by Tony Li »

Here's an updated scene: AsakuExample_2018-02-15.unitypackage

NPC1's second line uses the [pic=#] tag to temporarily show a different portrait image (a "surprised" variation). You can also use the SetPortrait() sequencer command to permanently switch portrait images.

NPC1's and NPC2's first lines use the AnimatorPlay() sequencer command to play various simple animations on the Portrait Images.

An alternate way to set up animated portraits is here.
User avatar
Asaku
Posts: 5
Joined: Tue Feb 13, 2018 5:15 pm

Re: Assistance Request

Post by Asaku »

Tony Li wrote: Thu Feb 15, 2018 8:40 pm Here's an updated scene: AsakuExample_2018-02-15.unitypackage

NPC1's second line uses the [pic=#] tag to temporarily show a different portrait image (a "surprised" variation). You can also use the SetPortrait() sequencer command to permanently switch portrait images.
I was playing around with the asset and I have noticed something... I cannot use sliced sprites for character portraits! I have mixed feelings about this as most of my sprites are sliced :(
Tony Li wrote: Thu Feb 15, 2018 8:40 pm NPC1's and NPC2's first lines use the AnimatorPlay() sequencer command to play various simple animations on the Portrait Images.
Neat, I will look into it for making a more complex demo scene.
Tony Li wrote: Thu Feb 15, 2018 8:40 pm An alternate way to set up animated portraits is here.
That's extremely useful! I will look more into it. We'll have to see budget wise if we can afford so many animations :P

Thank you for your awesome lightning fast responses!
User avatar
Tony Li
Posts: 22061
Joined: Thu Jul 18, 2013 1:27 pm

Re: Assistance Request

Post by Tony Li »

Hi,

With sliced sprites, you'll want to use the animated portraits method (linked again here for convenience).

Sprites didn't exist in Unity when the dialogue database format was established, so regular portraits use textures instead of sprites. This summer Dialogue System 2.0 will break with that convention and use sprites by default. Until then, the 1.x line will continue to use textures to avoid breaking existing projects.
User avatar
Asaku
Posts: 5
Joined: Tue Feb 13, 2018 5:15 pm

Re: Assistance Request

Post by Asaku »

Tony Li wrote: Sat Feb 17, 2018 10:18 am Hi,

With sliced sprites, you'll want to use the animated portraits method (linked again here for convenience).

Sprites didn't exist in Unity when the dialogue database format was established, so regular portraits use textures instead of sprites. This summer Dialogue System 2.0 will break with that convention and use sprites by default. Until then, the 1.x line will continue to use textures to avoid breaking existing projects.
Oh I see. That makes perfect sense. Good thing I've found a way to slice them easily so it shouldn't be much of a problem for now.

I'm having a hard time managing to get the list of currently available conversations in the database (for an ingame dropdown). Could you please tell me how can I get a hold of it and maybe some tips on how to be more autonomous in regard to the scripting aspect? Thank you.

EDIT: I've found the answer 5 minutes after making this question... :lol:
Post Reply