Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Dialogue System for Unity - easy conversations, quests, and more!

Discussion in 'Assets and Asset Store' started by TonyLi, Oct 12, 2013.

  1. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    Hello. Thanks for the previous answer. Next question.

    I want a part of UI to be set as not active when ANY dialogue starts. I don't want to add this to "OnExecute" events on each of the DialogueSystemTriggers. What is the correct way to do it? I wanted to modify DialogueSystemTrigger TryFire method, but that would probably break if I try to update.

    Same with any dialogue end
     
    Last edited: Jan 24, 2021
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Hi @Stickeyd - What about a Dialogue System Events component? If your dialogue UI is a child of the Dialogue Manager, or if it's instantiated into the Dialogue Manager's Canvas at runtime, then add a Dialogue System Events component. Configure the OnConversationStart() event to hide the UI element. If you want to show the UI element when the conversation ends, use OnConversationEnd() to show it.
     
  3. weto4ka

    weto4ka

    Joined:
    Feb 8, 2019
    Posts:
    48
    Yes, That what I have:
    upload_2021-1-25_11-47-6.png
    When I press play I have that:
    upload_2021-1-25_11-48-3.png
    But I need to start the conversation with a question (response panel). Thus, the user can choose which answer he wants to ask. Like this:
    upload_2021-1-25_11-52-4.png
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
  5. weto4ka

    weto4ka

    Joined:
    Feb 8, 2019
    Posts:
    48
    My question is: maybe there is some function that automatically changes the actor / conversant for all entries in conversation (to make them opposite)? because I want to use the same conversation and sometimes it starts with responses panel and sometimes it starts with npc subtitles.
    Or maybe there is some kind of UI tweak where I can check the box and the conversation starts with subtitles and if I turn it off it starts from the response panel without having to reverse actor/conversant for all entries in the conversation?
     
  6. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    @IspirationHappynes - Let's say your conversation looks like this:

    upload_2021-1-25_14-14-4.png

    The conversation's actor is Player. The conversation's conversant is NPC.

    And you have set up GameObjects with Dialogue Actor components for the Player and NPC:

    upload_2021-1-25_14-14-47.png

    ---

    If you assign the Player as the Dialogue System Trigger's Conversation Actor, and assign the NPC as the Conversation Conversant:

    upload_2021-1-25_14-16-4.png

    then the conversation will look like this:

    upload_2021-1-25_14-17-24.png

    ---

    However, if you swap the assignments on the Dialogue System Trigger:

    upload_2021-1-25_14-18-6.png

    this will tell the Dialogue System to use the NPC GameObject in all nodes assigned to the conversation's actor, and use the Player GameObject in all nodes assigned to the conversation's conversant. So the conversation will look like:
     
    weto4ka likes this.
  7. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
  8. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Mozq8 likes this.
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Ova Magica on Kickstarter

    Ova Magica's Kickstarter campaign is now open. If you like Pokemon, Stardew Valley, Slime Rancher, or Harvest Moon, make sure to check it out! (Ova Magica is being made with the Dialogue System for Unity!)

     
  10. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    Hi!
    So what I want to do:
    I want each character to have a color code. I saw this is easy.
    Then I want to use this code to color their name in the dialogue window.
    Is it possible to achieve this within the confinements of the dialogue system or do I have to go outside and script something myself?
     
  11. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
  12. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    I've tried to use that code, but actor is null all the time.
    I actually dont understand the solution at all, i cannot find any settings for subtitle colors, am I even using subtitles?
    I just need a reference to the actor object and I have searched for hours and cant find a way to get it...

    Code (CSharp):
    1. using UnityEngine;
    2. using PixelCrushers.DialogueSystem;
    3.  
    4. public class colorthemnames : MonoBehaviour // Add to Dialogue Manager
    5. {
    6.     public Color defaultNameColor = Color.white;
    7.  
    8.     void OnConversationLine(Subtitle subtitle)
    9.     {
    10.         var ui = DialogueManager.dialogueUI as StandardDialogueUI;
    11.         DialogueActor dialogueActor;
    12.         var panel = ui.conversationUIElements.standardSubtitleControls.GetPanel(subtitle, out dialogueActor);
    13.  
    14.         //Debug.Log(dialogueActor.GetName());
    15.  
    16.         if (dialogueActor != null)
    17.         {
    18.             panel.portraitName.color = Tools.WebColor(DialogueLua.GetActorField(dialogueActor.GetName(), "NodeColor").AsString); //dialogueActor.standardDialogueUISettings.subtitleColor;
    19.  
    20.             //Tools.WebColor(DialogueLua.GetActorField(dialogueActor.GetName(), "NodeColor").AsString);
    21.         }
    22.         else
    23.         {
    24.             panel.portraitName.color = defaultNameColor;
    25.         }
    26.     }
     
  13. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Hi @carmofin - You can put that script on the Dialogue Manager. You don't have to put it on each character. It will set the Portrait Name UI element to the actor's node color in the dialogue database.

    upload_2021-1-28_8-29-53.png
     
    Last edited: Jan 28, 2021
  14. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    Hi!
    As I said, the dialogue Actor is always null...
    How can I get the actor?
     
  15. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Did you want to get the actor's node color as defined in the dialogue database (shown in my post above)? Or the color as defined on the Dialogue Actor component?

    upload_2021-1-28_8-44-58.png

    The color defined on the Dialogue Actor component will also be used for the character's subtitle text. To use it, add a Dialogue Actor component to your characters' GameObjects. This is an optional component, but in the case of the original script in the forum post, it's required in order to change the color.

    If you want to use the node color defined in the dialogue database, here's a working version of the script:

    Code (csharp):
    1. using UnityEngine;
    2. using PixelCrushers.DialogueSystem;
    3.  
    4. public class colorthemnames : MonoBehaviour // Add to Dialogue Manager
    5. {
    6.     public Color defaultNameColor = Color.white;
    7.  
    8.     void OnConversationLine(Subtitle subtitle)
    9.     {
    10.         var ui = DialogueManager.dialogueUI as StandardDialogueUI;
    11.         DialogueActor dialogueActor;
    12.         var panel = ui.conversationUIElements.standardSubtitleControls.GetPanel(subtitle, out dialogueActor);
    13.  
    14.         // If we're using database's node color, we can ignore Dialogue Actor.
    15.         // Instead, get actor from database and use its node color.
    16.  
    17.         Actor actor = DialogueManager.masterDatabase.GetActor(subtitle.speakerInfo.id);
    18.         string nodeColor = actor.LookupValue("NodeColor");
    19.         if (string.IsNullOrEmpty(nodeColor))
    20.         {
    21.             panel.portraitName.color = defaultNameColor;
    22.         }
    23.         else
    24.         {
    25.             panel.portraitName.color = Tools.WebColor(nodeColor);
    26.         }
    27.     }
    28. }
     
  16. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    Ahhh, I wasnt aware of that component... Yeah I definately want to use the database, thank you!
     
    TonyLi likes this.
  17. DREBOTgamestudio

    DREBOTgamestudio

    Joined:
    Jan 30, 2018
    Posts:
    66
    Hello. Are you working on integration with the unity ui toolkit?
     
  18. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Possibly in the future. There are many issues with UI Toolkit right now, especially for runtime UIs. Even the front page of Unity's UI Toolkit manual has this warning:

     
    DREBOTgamestudio likes this.
  19. weto4ka

    weto4ka

    Joined:
    Feb 8, 2019
    Posts:
    48
    oh, thanks a lot, Tony:)
     
    TonyLi likes this.
  20. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Dialogue System for Unity - Version 2.2.15 Released!

    Version 2.2.15 is now available on the Asset Store!


    Release Notes:

    Core:
    • Added: OnShowAlert script message.
    • Improved: Can now specify Dialogue Manager's default canvas.
    • Improved: Added Wait For Close checkbox to Standard Dialogue UI.
    • Improved: If bark UI has typewriter effect, bark now starts it.
    • Improved: If conversation actor or conversant is unassigned, warning will appear in red in lower right of node editor.
    • Improved: Screenplay export now combines speaker name attributions for more compact text.
    • Improved: Dialogue Manager's Warm Up Controller mode now works with non-Canvas UIs.
    • Improved: Inspector does not draw dialogue database's default inspector when not showing a content-specific inspector (performance optimization).
    • Improved: ClearSubtitleText(all) now also clears custom subtitle panels, not just panels built into dialogue UI.
    • Fixed: Quest log window wasn't localizing group names.
    • Fixed: SetDialoguePanel(false) no longer resets the active conversation's cached subtitle panel overrides.
    • Fixed: When Selector is set to MousePosition, now reads InputDeviceManager instead of Input.mousePosition to support New Input System.
    • Fixed: Dialogue Editor search & replace could report error in certain situations.
    • Fixed: ConversationModel does not cache unassigned actor ID -1.
    • Fixed: VN Template Dialogue UI's Canvas Group animation.
    • Fixed: When showing actor names, text was too low on nodes in Unity 2020.
    • Fixed: Message System bug when removing and re-adding the same message listener in the same frame.
    • Cinemachine: Added CinemachinePriority(all) and (except:name) options.
    • Timeline: Conversation clips now have "Update Duration" button to set clip length to estimated duration of subtitle.
    • Localization Export/Import: Now also includes actor & quest Display Names.
    • Save System: Now handles loading old saved games that had quests that no longer exist in dialogue database.
    • Save System: LoadScene() logs message when Debug is ticked.
    • SaveSystem: Changed script execution order to -7.
    • SaveSystem: Added SavedGameData.DeleteData().

    Third Party Support:
    • Adventure Creator: Added Sync Lua action, Lua functions to get/set variable values and item counts.
    • articy:draft: Now sorts links to sub-dialogues by vertical position; arranges nodes vertically instead of horizontally by default.
    • Corgi: Added Also Disable Movement Components While Talking checkbox.
    • Ink:
      - Can now attach sequences to subtitles.
      - Now supports nested INCLUDEs with different relative paths.
      - Can now define scripting symbol INK_FULLPATHS to select entrypoints using full file paths.
      - Fixed issue with loop-back single response branches.
    • PlayMaker: Added Jump To Entry action.
    • Opsive Character Controllers (UCC): Added UIS define symbol to incorporate UIS-specific features.
    • Opsive Ultimate Inventory System (UIS): Updated for UIS 1.1.3; loading saved game no longer shows Inventory Monitor popups for restored items.
    • ORK: Updated for 2.30.2.
    • Twine: Added optional "(passthrough)" keyword to Conditions; fixed bug that created double links; can now import at runtime; arranges nodes vertically by default.
     
    DMRhodes and hopeful like this.
  21. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    Hi!
    I've been setting up the Scene transitions exactly like in the tutorial, but they do not work.
    The scene loads, but the empty "entry" gameobjects I set up are ignored and instead the player object loads in whereever I left it.
    Also the fade to black doesnt play at all, even though I set it up just like int he tutorial.
    I'm out of ideas, does anyone know any common mistakes?
     
  22. trojant

    trojant

    Joined:
    May 8, 2015
    Posts:
    89
    Hi!
    I want to drag the audio file to the sequence from Streaming Asset folder,and I modified "Resources" to "StreamingAssets" in SequenceEditorTools editor script,but still can't drag. How I can do,please? Thank you every much.
     
  23. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Hi @carmofin - Make sure the player has a Position Saver component whose Use Player Spawnpoint checkbox is ticked.

    For the fade to black, keep an eye on it in the Animator window. Make sure it's playing the fade animations, and that the canvas is set to be on a higher sort order than other canvases.

    The Dialogue System Extras page has a "SaveSystemPrefabs" package containing preconfigured prefabs that you can use or examine for ideas.

    In the next update, I'll add support for dragging audio files from StreamingAssets and also addressable assets. When you drag from StreamingAssets, files are not imported as the same types as from the rest of your project since they're loose, streamable assets. It will require some additional code to identify the file type and build the appropriate sequencer command.

    In the meantime, you can paste in the names. Also, consider using addressables over StreamingAssets. The Dialogue System has nice support for addressables.

    Even better, consider using entrytags.
     
    trojant likes this.
  24. trojant

    trojant

    Joined:
    May 8, 2015
    Posts:
    89
    Hi, 'OnConversationLine' This method will make the conversation run automatically on Dialogue system, I don't want this result.I just want it to run in every dialogue entry.What should I do,please? Thank you!
     
  25. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    It does run in every dialogue entry. It doesn't do anything to make the conversation run automatically or not. However, if you change the subtitle's sequence in OnConversationLine, this could affect whether it runs automatically or not. For example, if you were to add this to a script on the Dialogue Manager, every line would automatically advance after 1 second:
    Code (csharp):
    1. void OnConversationLine(Subtitle subtitle)
    2. {
    3.     subtitle.sequence = "Continue()@1";
    4. }
     
    trojant likes this.
  26. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    Hi!
    Got everything to work except one thing:
    The fade out animation plays fine when I leave a scene, but as I enter the new scene, the fade in never plays. The fade out will work fine upon leaving again though.
     
  27. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Is the fader canvas a child of the Save System? If it's a separate GameObject, and not in the Dialogue Manager/Save System's hierarchy, it won't survive the scene change. Since it plays the fade out in the next scene, though, it's probably a child.

    Check the settings on the Standard Scene Transition Manager. Make sure the fader canvas is assigned to the Enter Scene transition, and that it's set to the correct animation trigger. Keep an Animator window open on the fader canvas during the transition to make sure it's transitioning to the correct states.
     
  28. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    All of that seems to be set up correctly.
    When I enter the scene the animator shows the fading animation immediately at the end and then jumps to the default state.
     
  29. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Hi! Do you mean the blue bar jumps to the end of the fade-in state's node (e.g., Fade From Black node) instead of playing from the beginning of those node?

    In your project, does the fade in and out work correctly in the Dialogue System's demo scenes (e.g., DemoScene1 to DemoScene2)? If so, please compare the settings on your Standard Scene Transition Manager component with the demo's.
     
  30. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Great Kickstarters Now Live: The Way of Wrath and Ova Magica

    The Way of Wrath

    The Kickstarter for Animmal's prehistoric open world tactical RPG, The Way of Wrath, is now live. It uses Quest Machine, the Dialogue System for Unity, and Love/Hate. If you like games such as Baldur's Gate, tactical RPGs, or prehistoric open worlds, check it out.



    ---

    Ova Magica

    The Kickstarter for cute Pokemon-meets-Stardew Valley game, Ova Magica, blew past its initial funding goal in the first three hours and is now reaching all kinds of great stretch goals. If you like farming, monster taming, or life sim games, check out the Kickstarter to become a backer.

     
  31. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Here's a neat little mobile AR game that a Dialogue System user recently released for free:

    Storyhaven
    upload_2021-2-2_10-33-7.png
     
    weto4ka likes this.
  32. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    How do we actually control the order of the response menu? What are the rules behind it?
     
  33. weto4ka

    weto4ka

    Joined:
    Feb 8, 2019
    Posts:
    48
    Hi, Tony!
    I am trying to change the user interface of a response at runtime. And this is quite successful, but I have one problem:
    So, I made 2 scroll rectangles with response templates in 1 response pane and left 1 disabled and 1 active.
    upload_2021-2-3_14-2-27.png
    I found that if I change these 3 fields in my StandardUIMenuPanel (Response Panel) to the corresponding fields on one of my scroll rectangles, I can change the visualization of the menu in my Response panel. Here is that 3 fields: upload_2021-2-3_13-51-42.png
    But it only works as expected (loading responses in the menu) when I change everything manually before starting the scene. I do this by activating the scroll rectangle that I want and assigning these 3 fields in the StandardUIMenuPanel.
    I also made a script that does this automatically. When I press the button (it remembers the interlocutor and the actor and stops the current conversation. Activates the deactivated scroll rectangle and deactivates the active one. Then it assigns 3 fields to StandardUIMenuPanel. Then starts a new conversation using the modified answer menu options). But the problem is that the script does everything correctly, but when I start a new dialog, the responses are not loaded into the active scroll area that the script changed. By default, only 1 response template is displayed.
    Do you know that I still need to update so that it loads into the modified ScrollRect? Maybe I'm missing something
    Here is an example of how I change the scroll rects:
    I have a list with 2 scrollRects named scrollRects. I also have a ResponseUI containing these 2 scroll rectangles. To switch panels, I call ChangePanelSettigs (int x, int y) with two parameters, where x is the panel that is currently active and y is now deactivated, and swap them. Function also change the settings of these 3 fields in the ResponseUI.
    Code (CSharp):
    1.  
    2.  public StandardUIMenuPanel ResponseUI;
    3. List<ScrollRect> scrollRects = new List<ScrollRect>();
    4. void ChangePanelSettigs(int activePanel, int disabledPanel)
    5.     {
    6.         //Change to opposit activation of panels
    7.         scrollRects[activePanel].gameObject.SetActive(false);
    8.         scrollRects[disabledPanel].gameObject.SetActive(true);
    9.  
    10.         //Change response panel fields to previously disabled panel
    11.         foreach (Transform child in scrollRects[disabledPanel].transform)
    12.         {
    13.             if (child.name == "Scroll Content")
    14.             {
    15.                 ResponseUI.buttonTemplateHolder = child.GetComponent<Graphic>();
    16.                 ResponseUI.buttonTemplate = child.GetComponentInChildren<StandardUIResponseButton>();
    17.             }
    18.             else if (child.name == "Scrollbar")
    19.                 ResponseUI.buttonTemplateScrollbar = child.GetComponent<Scrollbar>();
    20.         }
    21.  
    22.     }
     
    Last edited: Feb 3, 2021
  34. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    It uses the node's Links To section. Say you have this conversation:

    upload_2021-2-3_9-29-21.png

    If the Links To section of the "What's your color?" node is:

    upload_2021-2-3_9-29-52.png

    then the response menu order will be:
    • Red
    • Green
    • Blue
    If you use the up/down arrows to move Green to the top:

    upload_2021-2-3_9-30-27.png

    then the menu order will be:
    • Green
    • Red
    • Blue
    However, if you have set different priority levels on the links, then it will check each priority level from highest to lowest, stopping when it finds a priority level with at least one valid menu item. For example, if you set the link to Blue to Above Normal:

    upload_2021-2-3_9-32-39.png

    then the menu will be:
    • Blue
    (It stops at Above Normal since it found a valid menu item there.)
     
  35. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Hi @IspirationHappynes - There is a much easier way. Add two menu panels:

    upload_2021-2-3_9-37-44.png

    Then use the SetMenuPanel() sequencer command to specify which panel to use. Example:
    • Sequence: SetMenuPanel(Player, 1) // Tell player to use menu panel 1.
    Or add a Dialogue Actor component to the participant, and specify which menu panel to use:

    upload_2021-2-3_9-42-40.png
     
    weto4ka likes this.
  36. weto4ka

    weto4ka

    Joined:
    Feb 8, 2019
    Posts:
    48
    thanks a lot, Tony!)
     
    TonyLi likes this.
  37. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    251
    Hi Tony

    i imported the package for Opsive Ultimate Inventory System Support, but there is a error wiht the item.

    thanks
     

    Attached Files:

  38. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Hi - You probably have a misbehaved script somewhere else in your project that defines "Item" without a namespace. Look for it and remove it (make a backup first) or put it in a namespace.

    Also make sure you're using the latest versions of UIS, DS, and the integration.
     
    claudius_I likes this.
  39. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Many Dialogue System-Powered Games In Steam Games Festival

    Check out some of the many game demos playable this week in the Steam Game Festival that use the Dialogue System for Unity! They include among others:

    Dwerve


    The Way of Wrath


    Beyond Mankind


    Framing Dawes


    Black Book



    Kickstarters

    The Way of Wrath and Ova Magica are both running very successful Kickstarter campaigns right now, too!

    The Way of Wrath - Kickstarter staff chose it as a Project We Love

    Ova Magica - Fully funded in the first 3 hours (!), and reaching all kinds of great stretch goals.
     
  40. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    The Adventure Mechanics: Stars Die Episode

    upload_2021-2-3_19-53-5.png

    If you like cosmic horror or sci-fi mysteries, listen to The Adventure Mechanics' latest podcast on Stars Die, made with the Dialogue System, and what they call a "cosmic horror walking simulator" and "a perfect little game". Beneath the surface of its retro PS2 aesthetic, the developer packed a lot of intricate dialogue into the hour long game. The show notes include an interview with the developer.
     
  41. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    251
    Hi again Tony :)

    I have a question about Ultimate inventory System integration and LUA in the "openshop method"


    "OpenShop([shop], [shopMenu], [playerInventory])

    Example: OpenShop()"


    how is the format with parameters?

    is like this?
    OpenShop([NPC_comprar_libreria], [Shop Menu], [claudioBoneNuevo Inventory]);
    or OpenShop(["NPC_comprar_libreria"], ["Shop Menu"], ["claudioBoneNuevo Inventory"]);
    or other format


    Thank Tony, your support is awesome :)
     
  42. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Hi @claudius_I - The [ square brackets ] mean the parameter is optional. Some examples:

    If you set the Sequence to this:

    OpenShop()

    then it will attempt to open the current speaker's shop if it has one.

    If you set the Sequence to:

    OpenShop(Bob)

    then it will attempt to open the shop owned by the GameObject named Bob.

    If you set the Sequence to:

    OpenShop(Bob, , Nolan)

    then it will attempt to open the shop on the GameObject named Bob, using the player inventory on the GameObject named Nolan. Notice I left the middle parameter blank, in which case it will default to "Shop Menu".
     
    claudius_I likes this.
  43. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
  44. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    Hi!
    I have a new issue! I staretd looking around the thread and documentation but it's always so hard to find precise documentation...
    So what I want to do: I want to play sound blips attached to the typewriter effect.
    Now I can attach one sound there and it will always play tha,t no problem.
    However, what I want to do is store the sound in the Actor and then have a different effect for each character.
    I haven't found a way how to do that. When I add a Files field to an actor, I havent found how to input my sound file into it.
    Also I have no idea if I can set this sound with a lua script and if so, how.
    Is there anything available that would help me?
     
  45. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Hi! This post explains how to do it. It also includes an example scene. Since each actor's audio file name is stored in a dialogue database field, you can set it in Lua:

    Actor["Someone"].AudioClip = "AdamMumble";
    (Setting it in Lua isn't required. It's just something you can do, since you asked.)
     
  46. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    Thanks, working wonderfully!
     
    TonyLi likes this.
  47. DREBOTgamestudio

    DREBOTgamestudio

    Joined:
    Jan 30, 2018
    Posts:
    66
    Greetings. Сould you help me? I want to change some words in a sentence depending on a variable. For example, if value = 0, then the character uses a random word from table 1 "{Нi / Hello / Greetings} traveler", and if value = 1, then the character uses a random word from table 2 "{Away / Glad to see you again} traveler ".
    In other words, automatic change of specific words to random from the corresponding tables, taking into account the change in the variable.

    p.s. I want to use a lot of different words, so pre-written blocks of text don't work.
     
  48. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Hi @DREBOTgamestudio - There are a lot of ways you can do it in the Dialogue System. I'll step through a few so you can decide what works best for your workflow.

    In the example below, the conversation branches on the variable named "value". If value = 0, it follows the left branch and uses the RandomElement() Lua function to randomly choose between "Hi", "Hello", or "Greetings". If value = 1, it follows the right branch.

    upload_2021-2-10_9-38-5.png

    If you don't want to put the random words in the dialogue entry node, you can put them into a variable:

    upload_2021-2-10_9-44-38.png

    Then, for the left branch, you could set the Dialogue Text to:
    • Dialogue Text: "[lua(RandomElement(Variable["greetings"]))] traveler"

    If you want to combine the left and right branches into a single node, you can use a longer Lua expression, such as:

    Code (Lua):
    1. [lua(RandomElement(Variable["value"] == 0 and "Variable["greetings"] or Variable["hello_again"]))]



    Alternatively, you can bypass all that and do a little C# scripting. Write a method that returns an appropriate word. For example:

    Code (csharp):
    1. string[] greetings = new string[] { "Hi", "Hello", "Greetings" };
    2. string[] helloAgain = new string[] { "Away", "Glad to see you again" };
    3. int value = 0;
    4.  
    5. public string GetGreeting()
    6. {
    7.     string[] table = (value == 0) ? greetings : helloAgain;
    8.     return table[Random.Range(0, table.Length)];
    9. }
    Then register the function with Lua and call it in your Dialogue Text: (video tut)
    • Dialogue Text: "[lua(GetGreeting())] traveler"

    An entirely different alternative is to manually process custom tags in your text. For example, set your Dialogue Text to:
    • Dialogue Text: "{greeting} traveler"
    Then add a script to the Dialogue Manager (or to the NPC if you want it NPC-specific) that has an OnConversationLine method such as:

    Code (csharp):
    1. void OnConversationLine(Subtitle subtitle)
    2. {
    3.     if (subtitle.formattedText.text.Contains("{greeting}")
    4.     {
    5.         randomGreeting = GetGreeting();
    6.         subtitle.formattedText.text = subtitle.formattedText.text.Replace("{greeting}", randomGreeting);
    7.     }
    8. }
     
    DREBOTgamestudio likes this.
  49. avazquez_mmg

    avazquez_mmg

    Joined:
    Feb 10, 2021
    Posts:
    1
    Hello,

    I am currently evaluating various Unity Assets to aid us in the development of a visual-novel/adventure style game project we are working on. We currently have been using Adventure Creator, which has out worked out fine so far but we are starting to notice some limitations as far as things we want to do with our dialogue tree creation. Adventure Creator is very similar; however, I'm noticing that Dialogue System appears to have quite a bit more functionality as far as configuring options for dialogue Speech-Text/Conversations/UI/Exports/Imports etc...

    One thing I noticed that Dialogue System has when creating dialogue speech nodes / conversations is the concept of an explicit conversant (i.e. lumped into the same dialogue node in addition to the speaker/Actor). In Adventure creator when you define a PlaySpeech event it only gives you the option to to specify the speaker, which in turn drives things such as: how the dialogue UI is displayed visually when the speaker talks, setting the speakers visual expression sprite, etc.... I'm curious what the use case was for having the conversant also explicitly called out and lumped in with the same dialogue node as the speaker? What I mean is what sort of benefits/features does having the explicit conversant lumped in with the speaker of a dialogue node give you?
     
    Last edited: Feb 10, 2021
  50. DREBOTgamestudio

    DREBOTgamestudio

    Joined:
    Jan 30, 2018
    Posts:
    66
    Wow, thank you very much, it helped me a lot!
     
    TonyLi likes this.