Search Unity

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

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

  1. fax58

    fax58

    Joined:
    Dec 27, 2021
    Posts:
    42
    Hi! I was wondering if there is a way to insert conditions (like a ternary operator or something) in a dialogue entry script field. Something like:

    Variable["Apple"] >= 3 ? Variable["Test"] = true;

    If is not possible, you think the best way to achieve this is by using something like a custom LuaFuncion to change the variable?
    Many Thanks!
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @fax58 - Lua has a "ternary-like" syntax:

    result = condition and true-value or false-value

    Example:

    Variable["Result"] = (Variable["Apple"] >= 3) and Variable["Test"] or true

    Alternatively, you could write a C# method that uses DialogueLua to get/set Lua variables, register your C# method with Lua, and use it in your Script field.

    Or use an if statement:

    if (Variable["Apple"] >= 3) then
    Variable["Result"] = Variable["Test"]
    else
    Variable["Result"] = true
    end
     
    fax58 likes this.
  3. fax58

    fax58

    Joined:
    Dec 27, 2021
    Posts:
    42
    Beautiful, Thank you!
     
    TonyLi likes this.
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Dialogue System-Powered Games In Steam Next Fest

    Check out tons of Dialogue System-powered games in Steam's Next Fest 2023 starting later today, including Metamorphosis Games' highly-anticipated Gestalt: Steam & Cinder:

     
  5. GrassWhooper

    GrassWhooper

    Joined:
    Mar 25, 2016
    Posts:
    109
    thanks that sounds perfect
    but i might have missed it, but is there a "skip all until new subtitle"
    example, if i were to show for the player a conversation 2 times, but the second time, there are a few new subtitles after it, that were not visited (based on conditions)

    is there a way to keep skipping until we reach the subtitles that the player has never entered before?
    the skip all appears to skip until there is a response menu (if i understood correctly)
    --------
    if there is not an option, how do you recommend i handle that? i am thinking of creating some dialogue variables for each node, where the variable name, is some unique identifier for the node, and it has a true or false value, where false means it was not read.

    so, i'd modify the ConversationControl script, to check if that variable is false or not, and if it is false, then, we stop skipping?
     
  6. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    The ConversationControl script doesn't do this, but you can tick the Dialogue Manager's Other Settings > Include SimStatus to track the status of each dialogue entry node (Untouched, WasDisplayed, or WasOffered [i.e., shown in response menu]).

    Then add a script with OnPrepareConversationLine(DialogueEntry) and OnConversationLine(Subtitle) special script methods to the Dialogue Manager. In OnPrepareConversationLine, record the entry's SimStatus since it will be changed before OnConversationLine is called. In OnConversationLine, check the SimStatus. Example:

    Code (csharp):
    1. private Dictionary<DialogueEntry, string> currentSimStatus = new Dictionary<DialogueEntry, string>();
    2.  
    3. void OnPrepareConversationLine(DialogueEntry entry)
    4. {
    5.     currentSimStatus[entry] = DialogueLua.GetSimStatus(entry);
    6. }
    7. void OnConversationLine(Subtitle subtitle)
    8. {
    9.     if (currentSimStatus[subtitle.dialogueEntry] != "Untouched")
    10.     {
    11.         // This isn't the first time this node is being used, so skip it.
    12.         subtitle.sequence = "Continue()";
    13.     }
    14. }
     
    GrassWhooper likes this.
  7. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Soul Tolerance in Steam Next Fest

    Also check out Chaosmonger's Soul Tolerance, which uses the Dialogue System, in Next Fest:



    Chaosmonger's latest game, Clunky Hero, which also uses the Dialogue System, just released last week!
     
    EpicMcDude likes this.
  8. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Hi!

    Just when I thought I was getting the hand of it, they throw me a curveball!

    I'm having some issues with sending this event to a Playmaker FSM:
    upload_2023-2-7_23-0-4.png
    I have a Dialogue Actor component specifying that the object is the actor Rodrigo, but no luck still. I have the FSMEvent() on Sequence and Script as I was just trying to see if one of them would work, but nothing seems to send the event over to the FSM.
    I also tried with the Dialogue System Trigger component to just test sending the event with On Conversation Start and play the Sequence, but no luck with that either. I'm confused as to what I'm doing wrong :/
     
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi! Let's go with the Sequence field, since you'll end up using one or the other, not both. Sequences have a simplified syntax; you don't need to put strings in quotes. Try:

    FSMEvent(Dialogue Add Impetuous, Rodrigo)

    If the GameObject named "Rodrigo" has more than one FSM, and if you only want this event to occur on the FSM named "Traits", try this instead:

    FSMEvent(Dialogue Add Impetuous, Rodrigo, Traits)
     
    EpicMcDude likes this.
  10. GrassWhooper

    GrassWhooper

    Joined:
    Mar 25, 2016
    Posts:
    109
    Thank you very much, that worked perfectly
    one small final question on this problem, i want it to be persistant and use some data and all using our own saving system.

    Should i save this new
    `Dictionary<DialogueEntry, string> currentSimStatus`
    manually to our saving system, or does this data get saved along side the dialogue system, when i use the
    PersistentDataManager.GetSaveData ?

    and if it does not get saved, how do you recommend i save the DialogueEntry ? like what variables are "keys" as i think i'll need to create SerializedDialogueEntry, that should contain key values/identifiers from the dialogue entry (if it does not get saved using the PersistentDataManager.GetSaveData).

    Again thank you very much
     
  11. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @GrassWhooper - You don't need to do anything extra. If you've ticked the Dialogue Manager's Include SimStatus checkbox, SimStatus will automatically be included in PersistentDataManager.GetSaveData().
     
    GrassWhooper likes this.
  12. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Ah! The quotation marks are what was throwing me off, works wonders now.
    But I'm curious to know why the FSMEvent() using the Script with Custom - PM/FSMEvent didn't work?
     
  13. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Two possibilities:
    1. If your Dialogue Manager GameObject didn't have a DialogueSystemPlayMakerLua component, it wouldn't have the FSMEvent() function.
    2. Don't include "actor:" in the front of the GameObject name. Just:
      FSMEvent("Dialogue Add Impetuous", "Rodrigo")
     
  14. fax58

    fax58

    Joined:
    Dec 27, 2021
    Posts:
    42
    Hi!
    I'm having some minor problems with the "WRPG Template Standard Dialogue UI".
    Basically yesterday I changed the ScrollRect.verticalNormalizedPosition from 0 to 1 (in dialogue panel -> main panel -> scroll rect -> scroll content -> subtitle text, OnCharacter Event) because, during long NPC responses, the slider was stucked at the botton and was not possible to read the text until the typewriting finish.

    With this modification now the scrollbar is stuck at the top, so is possible to read at the beginning but to read the whole message I need to wait until it finishes.
    My question is: even if the scrollbar is stucked, is there a way to scroll while the typewriting is going? Or the only way is to divide the dialogue and add a button to see the second part?

    I also noticed that, when the dialogue is very long, the responses don't show for a longer period compare to when the dialogues are short. Is there an option to set this timeframe?

    Sorry if I'm being unclear
    Many Thanks!
     
  15. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Please see Autoscroll Setup.

    The Dialogue Manager's Camera & Cutscene Settings > Default Sequence is Delay({{end}}). This delays for a duration based on the text length. To adjust {{end}}, reduce the Dialogue Manager's Subtitle Settings > Subtitle Chars Per Second. Or change the Default Sequence (e.g., to WaitForMessage(Typed)). More info: Cutscene Sequences
     
    fax58 likes this.
  16. fax58

    fax58

    Joined:
    Dec 27, 2021
    Posts:
    42
    Perfect, thank you very much!
     
    TonyLi likes this.
  17. GrassWhooper

    GrassWhooper

    Joined:
    Mar 25, 2016
    Posts:
    109
    Hey Thank you for your continuous support
    small question
    we will have in our game, things that happen in game world, based on the dialogue that is displayed
    is there a way to define custom markup tags?
    i did see a few posts about text mesh pro based tags, but i thought i'd ask which one to use
    for example, in the conversation node, we'd want to say something like `[myCustomUIPic]superPicName[/myCustomUIPic]`

    where somewhere in the code (that i am not sure where) i could process the text, get the tag in an easily way, and then just do my custom code, and load the "superPicName" and apply it in the customized places i wanted.

    so, do you have hints on making custom mark up tags, or maybe we should try and stick to text mesh pro tags? (and if the latter, could you share some place that explains parsing it if possible? )
     
  18. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi! You can process special tags or codes in your text in an OnConversationLine method.

    In your example, however, a custom sequencer command might be more appropriate.
     
    GrassWhooper likes this.
  19. ForgottenDreamcat

    ForgottenDreamcat

    Joined:
    Aug 26, 2022
    Posts:
    17
    Does Dialogue System now have support for Cinemachine 3, or is that still a work in progress?

    I tried upgrading my Cinemachine to Cinemachine 3 a short while back when it was first released, but it was not compatible with Dialogue System, so I am staying on Cinemachine 2.9.4 for now.
     
  20. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi - Cinemachine 3 is still in pre-release. When it's released, we'll add support.
     
    ForgottenDreamcat likes this.
  21. wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    Joined:
    Dec 22, 2021
    Posts:
    56
    I am learning how to use QuestMachine InventoryEngine support, but every time in the Demo scene, when I take three apples and return to the farmer's collision box, the Unity get stuck. I have to enable the task manager to close the Unity. I don't understand why it gets stuck?

    I use Corgi Engine and DialogueSystem to develop the game, and I want to use QuestMachine to produce the branch content in the game: randomly generated tasks and time-limited tasks. If I don't use QuestMachine, can I make randomly generated tasks and time-limited tasks with DialogueSystem?
     
  22. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Not without doing some custom programming. That's what Quest Machine is for. If you need procedurally-generated quests, I recommend using Quest Machine. If you're seeing an issue in your project, please post in the Quest Machine Unity forum thread or the Quest Machine forum section on pixelcrushers.com. There should be no issues with Quest Machine, Dialogue System, and Corgi Engine in a project.
     
  23. wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    Joined:
    Dec 22, 2021
    Posts:
    56
    Thanks for reply. If there is no problem with the demo scene, I will try again. It may also be that I set the fixed time step very low by 0.005, and the UI pop-up window is very stuck when it appears. Maybe I should change my computer :(((
     
  24. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Try Quest Machine's Demo scene in a new, empty project in which you've imported only Quest Machine. This will help you isolate the problem in your other project.
     
  25. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    flashframe likes this.
  26. fax58

    fax58

    Joined:
    Dec 27, 2021
    Posts:
    42
    Hi!
    I'm having a minor issue and checking the docs and previous answers on the forum didn't help.
    I have an NPC with audio that has two dialogue entries in a row. When the first one is done, the second one starts right away and I want to delay it for few seconds. I tried various commands in the first dialogue entry "sequence" and I believe the correct one is Delay(5).
    But when adding this, the dialogue audio does not play and the typing only lasts for the seconds I set, if is longer it gets cut. The audio is not in the sequence, I put all the audios in the resources folder and I'm using the entrytag format actorName_ConversationId_entriId. In the dialogue manager object, camera and cutscenes settings, default sequence, I'm using

    WaitForMessage(Typed);
    SALSA(entrytag);

    So my question is, how can I delay the second dialogue entry audio and text?
    Many thanks!
     
  27. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi! In the first dialogue entry, if you want to wait for 5 seconds after SALSA has finished playing the audio, set the dialogue entry's Sequence to:

    WaitForMessage(Typed);
    SALSA(entrytag)->Message(Spoke);
    Delay(5)@Message(Spoke)

    When a dialogue entry's Sequence field has any content, the entry will play its Sequence field instead of the Dialogue Manager's Default Sequence.

    Side note: If you want to play the Default Sequence as part of a dialogue entry's Sequence, you can use the keyword {{default}}. For example, to wait a minimum of 5 seconds, unrelated to the duration of the audio clip, you could do this:

    {{default}};
    Delay(5)
     
    fax58 likes this.
  28. fax58

    fax58

    Joined:
    Dec 27, 2021
    Posts:
    42
    Beautiful, works perfectly now!
    Is there a page in the docs where all the commands like Spoke are listed? I couldn't find it. I understand that Spoke will wait until the audio ends, but having some reference for understanding it better will be good.
    Thank you very much!
     
  29. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi - "Spoke" is an arbitrary message string that I chose for the example. You can read more about sequences here:

    Or watch the video tutorial series here:
     
    fax58 likes this.
  30. Bogu-94

    Bogu-94

    Joined:
    Dec 11, 2013
    Posts:
    58
    we're using the dialogue system for our cutscene engine, and so far I really like how I can code some custom sequence command for the artist.
    and now I feel like pushing the QoL for the cutscene guy a bit further by customizing the editor, if possible.

    so can we customize the dialogue inspector?
    say, inside the dialogue editor, there's a lot of fields we don't use (description, group, menu text, response, conditions, etc).
    or even adding my own functions/buttons so there's less sequence coding.
     
  31. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi - Those specific fields are mandatory, but you can add new, custom fields to the main inspector section. In the Dialogue Editor's Templates section, add a new field and tick the "Main" checkbox. To add the new field to all existing dialogue entries (or actors, or quests, or whichever template you edited), select Menu > Apply Template To Assets.

    The Dialogue Editor also provides several places where you can hook in your own code:
    Customizing the Dialogue Editor.
     
  32. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    Hi, Tony. Hard to see if this is a FAQ in 157 pages of thread, but I just tried the Quick Start steps on a plain empty project (2.2.34) in 2021.3 LTS. Step 15 gives no yellow hover text, no click response, no spacebar response. Distance from Camera is set to 30 but actual is 4 and NPC centered with collider. While I don't plan to use Selector ultimately, I am wondering if there's something obvious that might be missing. I tried "Default GUI" or not, I tried Spacebar, left-click, right-click, I did not enable New Input System in the project or in the Dialogue System Welcome window.
     
  33. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi - Please check How To: Fix Selector and Proximity Selector Issues.

    If that doesn't address your issue, please let me know so we can look into it further together.
     
  34. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    Thanks for the link. I had set up my NPC with the mesh and collider as a child of the Dialogue Trigger. Moving the collider up to the root of the NPC let DE get the events properly.
     
    TonyLi likes this.
  35. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Glad to help!
     
  36. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    I was wondering what's the best way to cue up or select from appropriate conversations conditionally. If I have a bunch of different conversations that an NPC might want to kick off, depending on various state (maybe Dialogue Database variables or quest states), what would I do to get the list of conversations that meet the condition? I see the Start Node for a conversation has a Conditions field, is that part of the solution?
     
  37. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi - Yes, use Conditions. In general, you'll want to leave the <START> node untouched, but you can put conditions on the nodes linked from <START>, or specify them in Dialogue System Trigger components' Conditions sections. I like to keep my conversation logic in one place (in the conversation), so I'll usually have a "hub" conversation that uses cross-conversation links to other conversations with conditions on them. Helpful info:
    If you want to get a list of conversations whose conditions are currently valid, without actually starting a conversation, you can check DialogueManager.ConversationHasValidEntry() on each conversation.
     
  38. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    Excellent. I saw the Detective example but didn't realize I could put that into a meta level "conversation", your term cross-conversation. I am not sure yet whether I like the meta tree or the ConversationHasValidEntry() approach better yet, but glad you gave both.

    Just for clarification, what specifically constitutes a "valid entry"? Is it the Conditions on the START node itself (the one you prefer to keep empty), or always the node(s) after the first link, or both? The docs seem to imply it's just the Conditions listed on the nodes after the first link.
     
  39. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Yes, just Conditions on the nodes linked from <START>.

    Maybe related/helpful:
     
  40. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    upload_2023-3-3_15-12-13.png

    Going to GDC 2023? Pixel Crushers is hosting a lunch at Oren's Hummus on Thursday, March 23!

    Do you use the Dialogue System for Unity? Come join us and share tips with fellow asset users, ask any questions you have, and enjoy some good food to fuel you through the rest of the day's activities at GDC.

    Space is limited, so please RSVP early by getting a free ticket on Eventbrite.

    Note: This event is hosted by Pixel Crushers and is not affiliated with the Game Developers Conference (GDC).
     
  41. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    I thought for sure there was an easy option to include Player's responses in the scrollback in the accumulated text, but now I can't find it. Currently, even the WRPG and SMS prefabs are just showing the NPCs history of lines.
     
  42. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi! The How To: Bypass Response Menu When Player Has One Choice article includes a screenshot that shows how to include player responses in accumulated text. Briefly: Tick the Dialogue Manager GameObject's Subtitle Settings > Show PC Subtitles During Line and UNtick Skip PC Subtitle After Response Menu.
     
  43. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    Ah, got it. I had the Skip PC because it plays the whole typewriter effect and also requires an extra Continue. Now it includes them. Once the PC clicks a choice, I'm hoping for an instant no-typewriter PC response added to the accumulated text and then let the NPC continue with the usual typewriter?

    Edit: Got it. Sequence: "Continue();" on Default Player Sequence and Default Response Menu Sequence.
     
    Last edited: Mar 9, 2023
    TonyLi likes this.
  44. wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    Joined:
    Dec 22, 2021
    Posts:
    56
    Hi Tony,I want to make a countdown task to zero, task failed/successful at DialogueSystem, how do I do it? I can't find a variable about time on and off.
     
  45. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi! The Dialogue System doesn't include a countdown timer, but you can add one of your own and register it with Lua to give your conversations access to it.
     
  46. wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    wechat_os_Qy0z_aF7Nfhquhava38GLxUWU

    Joined:
    Dec 22, 2021
    Posts:
    56
    Ok i get it! Thanks for mention that link!
     
    TonyLi likes this.
  47. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Peglin - A Peg Popping Post-Mortem

    Dylan Gedig recently did a great post-mortem of Red Nexus' hit game Peglin as part of the most recent IndieGameBusiness event and gave a nice shout out at 25:50 to the Dialogue System for Unity and some great assets that have Dialogue System integration such as Rewired and i2 Localization:

     
  48. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    527
    Hey @TonyLi , you're doing some pioneering work with the OpenAI integration asset, kudos. One question before I purchase it: does it or will it support GPT-4 in addition to the older models?
     
  49. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Yes, it supports GPT-4, assuming you already have beta access. GPT-4 is not available to everyone yet. If you don't yet have access, you can still use the other models, including GPT-3.5 Turbo, which is still the least expensive and fastest.

    A bigger announcement post is coming soon. I'm recording video tutorials right now. In the meantime, for anyone who's interested, you can get it here:

    Dialogue System Addon for OpenAI

     
    Last edited: Mar 17, 2023
    AGregori likes this.
  50. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    527
    Using Davinci003 daily in a paid plan, though apparently 3.5 Turbo is more advanced. GPT-4 is of course a game changer, can't wait to employ it in your integration.