Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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

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

  1. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Hi @unit102 - Here's a sample scene for Oculus VR:
    To play it, unpack the Windows build and run build_DirectToRift.exe. It's very simplified. I plan to make a more elaborate demo with full instructions in the future. In this version, when you walk up to the red soldier he'll start a conversation. Look at the responses to select them, and press Return to choose the current selection.

    To build it in Unity 4.6+, import the Dialogue System, the Oculus Unity Integration package (from Oculus's website), and the source unitypackage linked above. The scene is in a folder Assets/OVRScene. It uses BasicLookInputModule. The dialogue UI is a world space canvas. You can change the response choosing button by inspecting BasicLookInputModule on the EventSystem GameObject.
     
  2. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    "PlayMaker: Added FSM events OnRecordPersistentData, OnApplyPersistentData, OnLevelWillBeUnloaded."

    Can you clarify, what it the proper way to use those?
     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Hi @Gua - Here are the steps:

    1. Add the Dialogue System Events To PlayMaker component to the Dialogue Manager GameObject. This will listen for Dialogue System events and send them to PlayMaker FSMs. Assign the FSMs to the component's FSMs list.

    2. In your FSM, define the event, such as "OnRecordPersistentData". The events you can define are listed here.

    3. Create a transition that uses the event. For example, the "OnRecordPersistentData" event should transition to a state that records persistent data. In the state, record persistent data into the Lua environment using the Dialogue System Set Variable and/or Set Lua Field actions as described here.


    For example, say you have a music manager FSM, and you want to record the current song in saved games.

    1. Add Dialogue System Events to PlayMaker to the Dialogue Manager. Assign the music manager FSM to its FSMs list.

    2. In the music manager FSM, define the events "OnRecordPersistentData" and "OnApplyPersistentData".

    3. Add a transition for "OnRecordPersistentData" to a new state. In this state, use the Set Variable action to save the current song name to a variable, for example called "SongName". Then transition back to the previous state.

    4. Add a transition for "OnApplyPersistentData" to a new state. In this state, use the Get Variable action to retrieve the value of "SongName". Then play this song and transition back to the previous state.
     
    Last edited: Apr 8, 2015
    Gua likes this.
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    I received a question about the Oculus VR conversation scene and thought I'd post the answer here, too, in case it's helpful to others. The question was how to stop the conversation if the player walks away from the NPC. This is important in the Oculus scene because the conversation doesn't freeze the player's movement and camera control, since this wouldn't feel right in a VR experience.

    The Conversation Trigger component has a checkbox "Stop On Trigger Exit". I should have ticked this in the example scene. If ticked, the conversation will stop if the player walks away. (In the example scene, the Conversation Trigger is on the GameObject "Private Hart/AI".)

    Another way to stop the conversation if the player gets too far is to add a Stop Conversation If Too Far component.

    You can also press the Escape key to cancel the conversation. You can configure this key on the Dialogue Manager GameObject.



    There was also a related question about how to do HUDs like the quest tracker HUD or a compass system in Oculus. You can add another world space canvas as a child of the OVRCameraRig. This way it will always be in front of the player's eyes. Move it about 1 unit away from the OVRCameraRig, and size it so it fits in the camera's viewing area.
     
  5. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    @TonyLi I didn't use it yet, but so far it looks good. Thank you for implementing this! But there's one thing I don't like, so I want to make feature request. Is it possible to add option to send those events to all FSMs in a scene. I know, that if it's possible, it is not the most efficient way to do it, but I would still love to have that option.
     
    Last edited: Apr 9, 2015
  6. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Hi @Gua - I just added your request to the list for the next version!
     
    Gua likes this.
  7. unit102

    unit102

    Joined:
    Nov 13, 2014
    Posts:
    26
    Thanks TonyLi, you are the best :)
     
    Gua likes this.
  8. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Version 1.4.9 is now available on the Asset Store!
     
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    New PlayMaker Support Package

    There's a new PlayMaker Support package on the Pixel Crushers customer download site (PM me your Asset Store invoice number for access) that you can also download right here.

    It adds:
    • Optional 'all' keyword for the FSMEvent() sequencer command that sends an event to all FSMs in the scene. Example: FSMEvent(ResetHealth, all)
    • New actions to manage changing levels and saving games with full Dialogue System persistent data support:
      • Load Level
      • Save Game
      • Load Game
     
    Gua likes this.
  10. unit102

    unit102

    Joined:
    Nov 13, 2014
    Posts:
    26
    Hi Tony,
    Can I switch between different cameras (OVRcameras since I am using Oculus) during dialogue conversation without hurting the performance?

    thanks.
     
  11. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Hi @unit102 - It won't hurt performance, but I don't recommend this. When you disable an Oculus camera, it sometimes turns off your Oculus device. Also, it can be very disorienting to the player to change camera views in VR. The player should always be in control of where he or she is looking. If you must control the camera, however, assign it to Dialogue Manager's alternate camera object, which was added for this purpose. Then all camera-related sequencer commands, such as Camera(), will work with it.
     
  12. RealAspireGames

    RealAspireGames

    Joined:
    Dec 24, 2013
    Posts:
    265
    Hello TonyLi!
    So recently I have upgraded to Unity Pro and I am loving it so far! But with the dialog system on one of my quests I am getting this error and it is not letting me do the quest! Is there any way I can fix this!


    Dialogue System: Lua code 'Quest["Find_the_radioactive_suit"].State = "active";
    Variable["Alert"] = ""New Quest: Find a hazmat suit""' threw exception 'Code has syntax errors:
    Line 3, Col 1 : Failed to parse Letter of Name.
    Line 3, Col 1 : Failed to parse Name of VarName.
    Line 3, Col 1 : Failed to parse 'nil' of NilLiteral.
    Line 3, Col 1 : Failed to parse Text of BoolLiteral.
    Line 3, Col 1 : Failed to parse '0'...'9' of Digit.
    Line 3, Col 1 : Failed to parse (Digit)+ of FloatNumber.
    Line 3, Col 1 : Failed to parse Name of VariableArg.
     
  13. RealAspireGames

    RealAspireGames

    Joined:
    Dec 24, 2013
    Posts:
    265
    Never mind I have resolved the issue! Turns out I had 2 quotation marks on a variable! :D
     
  14. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Glad it's working now!
     
  15. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    Hey Tony,

    Is there a way to disable "Escape" from closing the dialogue window?
     
  16. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Hi @landon91235 - Yes, inspect the Dialogue Manager, and set Display Settings > Input Settings > Cancel Conversation > Key to None.
     
    landon912 likes this.
  17. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Dialogue System 1.4.9.1 Released!

    Version 1.4.9.1 is now available on the Pixel Crushers customer download site. (PM me your Asset Store invoice number for access.) It should be on the Asset Store in a few days!

    This update contains some minor improvements and bug fixes. Next up: Unity UI video tutorial!


    Version 1.4.9.1

    Core
    • Improved: Override Actor Name now has a button to assign a unique internal name for persistent data components.
    • Improved: Added Copy Conversation menu item.
    • Improved: Dialogue Editor now shows Description field in dialogue entry's main edit section.
    • Fixed: Localization field was using a dropdown instead of a text field.
    • (Unity GUI) Improved: QuestTracker has a new checkbox to show successful and failed quests.
    Third Party Support
    • Action-RPG Starter Kit: Fixed bug in RemoveItem() that left icon in inventory slot when count reached zero.
    • NGUI: QuestTracker can show title or description.
    • PlayMaker: Added FSMEvent(eventName,all) to send event to all FSMs in scene. Added LoadLevel, LoadGame, SaveGame actions.
     
  18. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    • Optional 'all' keyword for the FSMEvent() sequencer command that sends an event to all FSMs in the scene. Example: FSMEvent(ResetHealth, all)
    I'm not exactly sure how to properly use it, and what is its purpose? Especially since, Playmaker can already send events to all FSMs
     
  19. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    This allows you to send an event to FSM(s) from a dialogue entry's Sequence field.
     
  20. ndef

    ndef

    Joined:
    Oct 13, 2009
    Posts:
    7
    I'm brand new to Dialogue System, so please excuse my ignorance. I'm trying to call a very simple function on the DialogueManager through C# script, but I'm having some trouble actually accessing it. When I try simply addressing "DialogueManager" it isn't recognized and I get an error telling me the name does not exist in the current context.

    I have a Dialogue Manager object in the scene, set up properly with a DialogueSystemController component and working, so I know I have Dialogue System set up in the project. My understanding is that DialogueManager is a static class, so I should be able to access it without any specific reference. Maybe this has something to do with the fact all of the system's scripts are compiled into DLLs? I haven't worked with DLLs on a project in Unity before. Or is there a namespace I should be using?

    I'm sorry to ask such a basic question, but I haven't been able to find any reference to this issue in the documentation or on the forum. Not sure why I'm having this problem and no one else seems to. Any advice is appreciated!
     
  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Hi @ndef - At the top of your script, add this line:
    Code (csharp):
    1. using PixelCrushers.DialogueSystem;
    All of the Dialogue System code is in the PixelCrushers.DialogueSystem namespace to ensure that it doesn't conflict with any other products. The using line above tells C# to look in this namespace when looking for things like DialogueManager. (It doesn't have anything to do with DLL vs. script. BTW, source code is included should you want to refer to it or modify it.)
     
  22. ndef

    ndef

    Joined:
    Oct 13, 2009
    Posts:
    7
    This is exactly what I was looking for; thank you so much!
     
  23. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Glad I could help!
     
  24. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Unity UI Tutorial


    I kept this tutorial fairly high level. If you have any questions about customization or fine details, please ask!
     
  25. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Version 1.4.9.1 is now available on the Asset Store!
     
  26. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Dialogue System v1.4.9.2 Released!

    Version 1.4.9.2 is now available on the Pixel Crushers customer download site. (PM me your Asset Store invoice number for access.) It should be on the Asset Store in a few days!

    This update contains a bug fix for the Dialogue Editor's Copy Conversation feature. The origin conversation ID wasn't being set correctly in links in the copied conversation.

    Version 1.4.9.2 also contains an updated Adventure Creator support package. NOTE: The Dialogue System actions were moved from "Custom" to "Third Party". You may have to reconfigure your Dialogue System actions if Adventure Creator doesn't detect the change properly.


    Version 1.4.9.2

    Core
    • Fixed: Bug in Dialogue Editor’s Copy Conversation function caused link origin conversation ID to be set incorrectly.
    Third Party Support
    • Adventure Creator:
      • Breaking Change: Dialogue System actions were moved from “Custom” to “Third Party”. You may have to set up your Dialogue System actions again.
      • Added: Sequencer Message action, option to save to global variable in Lua action.
      • Fixed: Camera control bug when camera control was set differently from player control.
     
  27. benflock

    benflock

    Joined:
    Jul 11, 2013
    Posts:
    24
    Hi Tony

    quick thing, trying to get playmaker working with the dialogue system and there are two things i can't figure out

    one is that i don't seem to be able to use the Get Variable action every frame, if i update a variable in the dialogue it doesn't register, is there a particular way to use this?

    and secondly i can't seem to get FSMEvent() to send anything out, i have placed the component on the manager but nothing is being sent, even if i try and use the new 'all' method

    do i have to declare the event as a global event and is there anything else i need to do in order to get it working?

    thanks

    b
     
  28. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Hi @benflock - I haven't tried getting the variable every frame. I'll test this out and get back to you. Generally speaking, though, if you can avoid getting the variable every frame that would be better. It's not as expensive an operation as, say, GetComponent, but it does take a little time to reach into the Lua environment. Then again, if you're only doing it during a conversation, it's probably negligible.

    Declare it as an event in your FSM. Take a look at the FSM in the example scene. Let me know if you'd like me to post some screenshots here; if so, I can do that later today.
     
  29. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
  30. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Sorry, I introduced a bug in the latest update and didn't catch it. You can download a fixed PlayMaker support package here or on the Pixel Crushers customer download site. The bug prevented the Every Frame checkbox from taking effect in the Get Variable and Get Lua Field actions.

    Take a look at the gray cube in the Dialogue System's PlayMaker Example scene. It's called "FSM Event Trigger", and it's usable. Look at it and press the space bar. This will tell FSMEvent() to send the event "Test Sequence" to the Dialogue Manager:



    In the Dialogue Manager's FSM, I defined an event "Test Sequence". When the FSM gets this event, it transitions to a state that fades the screen out and back in:

     
  31. benflock

    benflock

    Joined:
    Jul 11, 2013
    Posts:
    24
    hi Tony

    brilliant thanks
    that all works like a dream

    one more little one, trying to send a onSequencer message from playmaker but can't seem to get it to come accross, how would i do that?

    thanks a lot

    b
     
  32. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Hi @benflock - Which direction are you going?

    PlayMaker --> GameObject/Script:
    Normally the Dialogue System sends OnSequenceStart and OnSequenceEnd messages to both participants of the sequence (if either are defined), passing the transform of the other participant. To mimic this, you'd send this message:
    Code (csharp):
    1. targetGameObject.SendMessage("OnSequenceStart", someTransform);
    The PlayMaker Send Message action doesn't let you send transforms, so you'd have to write a custom action for this.

    Dialogue System --> PlayMaker:
    To set up your FSM to receive Dialogue System-generated messages such as OnSequenceStart, add a Dialogue System Events To PlayMaker component. In the FSMs list, specify the FSM(s) that should receive messages. Take a look at the example scene: The Dialogue Manager's FSM handles OnConversationStart and OnConversationEnd messages. It logs receipt of these messages to the PlayMaker Log Window.

    Start a Sequence from PlayMaker:
    To start a sequence from PlayMaker, just add the Start Sequence action. Enter the sequencer commands in the Sequence field.

    Are any of those what you're looking for?
     
  33. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    Hey Tony. How's it going? I'm FINALLY getting back into the dialogue stuff and I have a couple of questions.

    1. How do I use my own UI for quests? You were talking about this last year sometime, but I'm not sure what became of it or how I can use my own system for dealing with this.

    2. Are conversation/quest variables still handled by LUA? Can we use our own variables for this now?

    3. Is it still easier to use Chatmapper for doing dialogs and quests? Is there a better way now? Not sure what the options are these days.

    I'm gonna try to make my first quest tomorrow and see how it goes, but I'm all updated and ready to give it a serious run...again. Keep up the good work and I look forward to working with you again.
     
  34. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Hi @EDarkness - I recommend using the new Unity UI.
    • A quick video tutorial intro to Unity UI in the Dialogue System is here. (all tutorials)
    • Instructions for setting up a Unity UI quest log window are here. It includes instructions for the quest log window (which the player can open to review quests) and quest tracker HUD (which shows quest states during gameplay).
    • The Quest System documentation is here. (Quests video tutorial is here.)
    • The Dialogue Editor section for quest data is here.
    Legacy Unity GUI works fine, too, as do the other GUI systems such as NGUI, so it's your choice.

    Briefly, here are all of the steps to add quests:
    1. Add quests to your dialogue database.
    2. Add a script to the Dialogue Manager that allows the player to open the quest log window. You can use FeatureDemo.cs as a temporary stand-in script.
    3. Import the Unity UI Support package (in the Scripts folder).
    4. Set up a quest log window.
      • Create a Canvas (GameObject > UI > Canvas). Move the Canvas under the Dialogue Manager so it survives scene changes.
      • Drag Scripts/Supplemental/UI/Prefabs/Quest Log Window/SF Quest Log Window into the hierarchy under the Canvas.
      • Assign the SF Quest Log Window scene object to the Feature Demo's Quest Log Window field.
    5. Set up a quest tracker HUD.
      • Drag Scripts/Supplemental/UI/Prefabs/Quest Log Window/SF Unity UI Quest Tracker HUD under Canvas.
      • Add a Unity UI Quest Tracker component to the Dialogue Manager, and assign the SF Unity UI Quest Tracker HUD components to its fields. (See the example scene.)
    6. In conversations, you can use the Lua wizards to check and set quest states without having to type any Lua code.
    7. If you have kill/collect quests, add Increment On Destroy components to the targets. When the targets are destroyed, they'll update the counter and tell the quest tracker HUD to refresh itself.
    The steps above use a couple sci-fi prefab UIs. You can swap out the textures and fonts, change the layout, etc. Using the prefabs is just a way to see things running quickly.

    They're still handled by Lua, but there are plenty of ways to tie your own variables to the Lua variables. What do you have in mind?

    For conversations and barks, it's a matter of preference. Some people prefer Chat Mapper's interface, some prefer the Dialogue System's built-in editor. (And others use articy:draft or Neverwinter Nights!)

    If you plan to have a lot of quests, use the built-in editor. Chat Mapper doesn't have a concept of quests, so it can be a bit awkward working with quests.

    Good luck! If any questions come up, don't hesitate to post or email me directly at tony (at) pixelcrushers.com.

    Quests are a lot more powerful and flexible than a year ago. Some teams have made some amazingly elaborate quests. I didn't mention Quest Triggers and Condition Observers, but they're both very handy for managing quests.
     
    Last edited: Apr 20, 2015
  35. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    Hey Tony. I'm using NGUI. It's too late for me to switch to Unity's UI. What would I need to do to include that information in my own GUI setup? I have a specific place for quest stuff. Basically, the player opens the Character Info window and then has the option to tab over to the Quest section. Can this be done?

    *EDIT* I realized that I have edited some NGUI scripts to get the conversation system to play nice with my setup, though, I admit that I haven't messed with that stuff in almost a year now. I guess I'll have to do the same thing for quests. I mainly need the information and for the system to check if things have happened and send system messages when necessary (i.e. "Quest updated.", "Completed quest.", etc.). I have places for that to happen in my GUI setup, but I guess I'll need to know how to access that as I didn't see any new files in the NGUI files I downloaded a few days ago.
     
    Last edited: Apr 20, 2015
  36. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Sure. Just today, coincidentally, I was working with a developer on this very thing with an NGUI interface.

    It depends on how much UI functionality you want to inherit from the NGUIQuestLogWindow class. Keep in mind that the Dialogue System maintains a tidy separation of data and UI. You could forgo NGUIQuestLogWindow entirely and manually grab data out of the Dialogue System instead if you prefer.

    But if you want to use NGUIQuestLogWindow, add the script to your character window. Then assign the controls (Main Panel, Active Quests Button, Completed Quests Button, etc.). When the player tabs over to the Quest section, call the script's Open() method. When the player tabs to a different section, call the script's Close() method.

    Make sure you've imported the "Third Party Support/NGUI 3.x Support" package that came with the latest version of the Dialogue System. The most recent improvements are in v1.4.9.1. Make a backup copy of your scripts first to save any customizations you've made.

    The manual's How to Manage Quests section should also be helpful for what you're describing.
     
  37. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    How customizable can we have the quest window? I noticed that the quest setup now is some kind of dropdown window. I was thinking something along the lines of the quest name on the left and the information on the left with some extra information such as how many items have been collected (for collect quests) somewhere on the panel.
     
  38. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    The dropdown is the default appearance. To do something different, create a subclass and override the OnQuestListUpdated() method:
    Code (csharp):
    1. using UnityEngine;
    2. using PixelCrushers.DialogueSystem;
    3. using PixelCrushers.DialogueSystem.NGUI;
    4.  
    5. public class MyQuestLogWindow : NGUIQuestLogWindow {
    6.  
    7.     public override void OnQuestListUpdated() {
    8.         // Your code here.
    9.     }
    10. }
    In this method, you can set up your display using the the Quests[] array property, SelectedQuest, and NoQuestsMessage. This is how they're defined:
    Code (csharp):
    1.        public class QuestInfo {
    2.             public string Title { get; set; }
    3.             public FormattedText Heading { get; set; }
    4.             public FormattedText Description { get; set; }
    5.             public FormattedText[] Entries { get; set; }
    6.             public QuestState[] EntryStates { get; set; }
    7.             public bool Trackable { get; set; }
    8.             public bool Track { get; set; }
    9.             public bool Abandonable { get; set; }
    10.         }
    11.  
    12.         /// <summary>
    13.         /// The current list of quests. This will change based on whether the player is
    14.         /// viewing active or completed quests.
    15.         /// </summary>
    16.         public QuestInfo[] Quests { get; protected set; }
    17.  
    18.         /// <summary>
    19.         /// The title of the currently-selected quest.
    20.         /// </summary>
    21.         public string SelectedQuest { get; protected set; }
    22.  
    23.         /// <summary>
    24.         /// The message to show if Quests[] is empty.
    25.         /// </summary>
    26.         public string NoQuestsMessage { get; protected set; }
    (If you've assigned a localized text table, NoQuestsMessage is the localized version of the text.)

    The quest journal in Tortured Hearts, for example, looks like an open book. Their overridden OnQuestListUpdated() adds the quest titles on the left page as clickable buttons. When the player clicks on a quest title, it shows the quest details on the right page.
     
  39. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    Hmmm...would it be possible to just get at the root of the whole system? I just looked at my main chat script and basically it just accesses the system directly without the need for any of the GUI things. I'm gonna go ahead and work with what you've posted here to get started, though. Figure it'll give me a chance to figure the whole quest thing out and to get that system into the game properly. I can work on refinement later, I guess.
     
  40. benflock

    benflock

    Joined:
    Jul 11, 2013
    Posts:
    24
    Hi Tony

    thanks,
    i'm trying to send a message to move a conversation on from WaitForMessage()

    tried to do it with the playmaker 'send message' action but can't get it to send at the moment

    thanks

    b
     
  41. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Hi @EDarkness - you'll probably want to use the QuestLog class (API reference). For example, you can call QuestLog.GetAllQuests(QuestState.Active) to get a list of all active quests, or QuestLog.CompleteQuest(questName) to mark a quest as successfully completed.

    Hi @benflock - The sequencer's message system is separate from Unity's. In the support package for the next release, I've included a PlayMaker action to send sequencer messages to the sequencer. I'll put the support package on the Pixel Crushers customer download site later today and post a link here.
     
  42. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    Thanks for the information, Tony. By the way, I was wondering if it was possible to allow text inputs to be part of the conversation system. For example, if one of the NPCs says, "Ask Bob about 'cookies'." So the player then finds Bob and one of the choices is to type something in. The player types 'cookies' and Bob has a response. Kind of like the old Ultima games back in the day.

    I got some ideas about the quest stuff, so I'll see what I can do about it later today. Been kinda crazy, so I haven't had much time to mess around with it.
     
  43. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Hi @EDarkness - Add a Text Field UI to your dialogue UI. Then use the TextInput() sequencer command.

    To see it in action, play the demo scene and interact with the Terminal. (You need to talk with Private Hart first.) Or play the NGUI demo scene that has "with Text Input" in its name and talk to Hart.
     
  44. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Version 1.4.9.2 is now on the Asset Store!
     
  45. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    I think I'm totally lost, man. Looking at how everything is laid out is kinda throwing me for a loop. Maybe I need to step away from this a bit. I do have a question, though. What is the situation with passing on EXP gained, money, items and such upon completion? Require messing around with LUA?
     
  46. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Generally speaking, you only ever need to mess around with Lua if you want to. It's usually easier to use C# or UnityScript. For example, say you want to know if the quest "Kill the Goblin King" is active. Use this line in C#:
    Code (csharp):
    1. var isActive = QuestLog.IsQuestActive("Kill the Goblin King");
    For another example, say you've defined a field named "EXP" in your quests in the dialogue database asset. Use this line in C# to get the EXP gained for the quest:
    Code (csharp):
    1. var exp = DialogueLua.GetQuestField("Kill the Goblin King", "EXP").AsInt;
    I recommend taking one thing at a time. The four major pieces are:
    1. Dialogue Database: The asset containing your data (e.g., quest definitions, conversations, etc.).
    2. Data Access: Use the QuestLog and DialogueLua classes to get data into and out of dialogue databases.
    3. Tracking Quests: Use components like Increment On Destroy to update quest-related counters.
    4. User Interface: Show quest info in your character window.
    Maybe start with #1 by defining a quest in your dialogue database. Then play around with the QuestLog and/or DialogueLua methods to access the quest's data in your own scripts.

    Since every game is different, it's up to you to decide what to do when a quest is completed. Using the example above, your script could get the value of the "EXP" field and use it to give experience points to the player. If you've defined a reward item field, you could get this field and give the named item to the player.

    It's also up to you to decide how to detect when a quest is done. Some games, like WoW, handle most everything through conversations. You talk to a quest giver to start the quest, and you talk to the quest giver again to complete the quest. Other games handle most of the quest updates during regular gameplay. For example, if you have a "Find the Demon Gate" quest, you can add a Quest Trigger in front of the gate. When the player enters the trigger area, it completes the quest.

    The manual has a quest case study for a quest that was implemented in a zombie survival game.

    This is probably a digression, but one innovative team actually put a short Lua program in a quest field. When the player completed a quest, they ran the Lua program. Since you can register your own C# methods with Lua, it allowed them to run an entire small program (including their own C# code) defined entirely by the designer in the dialogue database.
     
  47. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,569
    Hi @benflock - You can download the updated PlayMaker Support package here or on the Pixel Crushers customer download site. The action is named "Send Sequencer Message".
     
  48. EDarkness

    EDarkness

    Joined:
    Feb 1, 2013
    Posts:
    506
    Good advice. I've already got a quest laid out, so now is just the issue of getting the data. I'll figure it out, so no troubles there.

    I think the biggest problem has been getting the GUI to cooperate. But luckily, I got it working. I'll have to do a lot of refining to get it functioning exactly the way I want it, but right now I can pick up a quest and it shows up in the log.

    Not bad after a day in the trenches. Gonna try some more complex quests tomorrow and get things refined as far as how quests are displayed. Your information was extremely helpful. I'll have more questions tomorrow to be sure. Especially in how to get variables out of the system. I'm still a little fuzzy on it and some guidance would be good. :)
     
  49. benflock

    benflock

    Joined:
    Jul 11, 2013
    Posts:
    24
    brilliant

    thanks a lot

    b
     
  50. Pedro-Alaiagames

    Pedro-Alaiagames

    Joined:
    Apr 15, 2014
    Posts:
    28
    Hello!

    I'm implenting the dialogues of a game with a Dialogue DataBase for every NPC. I would want to know how to implement a 3 characters dialogue, 2 NPCs and the Player, in the same dialogue.

    Is this a proper implementation?

    In the dialogue database I define 3 actors, but how can I define the camera angles for three characters?

    Any tip about this?

    Thanx.
     
    EDarkness and Dreamaster like this.