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. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    @Darkkingdom - Your GameSaver needs a LevelManager on the same GameObject or a child GameObject. (Sorry, I need to bring that out more clearly in the documentation.) If you add a LevelManager, it should work.

    Here's an updated example that does it all: GameSaverExample_2016-01-17.unitypackage

    To play the example, add Game Saver Example Scene 1 and 2 to your build settings.

    If you play from Game Saver Start Scene, it will attempt to load the saved game in slot 0 (if any). To do this, it uses a Dialogue System Trigger set to OnStart. The trigger's action sends "LoadGame" 0 to the GameSaver.

    If you play from Game Saver Example Scene 1, it won't try to load saved game 0 at start.

    You can move back and forth between scenes 1 & 2 and save in either scene. The example will remember which scene you saved in. When you load, it will return to that scene.
     
    Darkkingdom likes this.
  2. Darkkingdom

    Darkkingdom

    Joined:
    Sep 2, 2014
    Posts:
    81
    Oh boy you really earned you 5 stars for the support :)
    I wish I can say it works now, but there is still an issue :( (I'm so sorry)

    I added the LevelManager to the GameSaver and set everything up in a similar way, like in your fantastic example above.
    But now there is a new problem, it looks like it loads the gameplay scene twice.
    After the LoadGame message from the startmenu is send, the first gameplay scene loads and after a few frames the player is at the position I saved.
    But then the damn scene reloads again and I'm at the default position, with none of my saved data :(

    I'm absolutely sure, that I have just one load message of the GameSaver and have no script call or something that could execute the second loading scene.
    My gameplay scene (x1) also appears just once in the build settings.

    I documented the whole process after the message in the start scene is called:





    This is what I set up for the startmenu:


    And this is for the gameplay scene:



    I really don't know from what the second x1 scene comes.

    Oh and don't wonder about the missing startscene and default startscene information.
    I deleted them for testing^^

    Its interesting that I have the same error, when I'm trying to load the savegame and the x1 scene from the start example sence you made for me. So my start scene can't be the error?

    I'm sure we are close to the finish :)
     
    Last edited: Jan 18, 2016
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Hi @Darkkingdom - Thanks for the screenshots. I'll try to set up the same scenario here. Would it be possible for you to send a copy of your project to tony (at) pixelcrushers.com? I'd be happy to take a look at it directly.
     
  4. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    Hello , how to make objectifs? For example a npc who said to go to this house or retrieves the object ...
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Hi @Ludo97 - The Dialogue System calls these "quests." You can read about them in the Quest System section of the manual or watch the video tutorial.
     
  6. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    @Darkkingdom - No need for your project. I figured out how to reproduce the issue. I have to step out for a bit, but as soon as I get back I'll send you a solution.
     
  7. schipman

    schipman

    Joined:
    Jan 22, 2010
    Posts:
    45
    I just bought this asset and I'm already having a ton of fun with it. I'm wondering though, the EnableonDialogueEvent script is so useful- is there something like that for Enabling based on Quest state? I was thinking of toggling on objects based on where the player is in the quest. Thanks!
     
  8. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Hi @schipman - Thanks; I'm glad you're having fun with it! There currently isn't an equivalent for quest state changes, but it's on the roadmap for a future version of the Dialogue System.

    However, you can use the Set Component Enabled On Dialogue Event and Set Active On Dialogue Event components' Conditions right now to handle a lot of cases. Say you know that a quest state changes during a conversation. At the end of the conversation, if the quest is active you want to enable a GameObject. If the quest is successful you want to disable the GameObject.

    To do this, add two On End elements to your Set Active On Dialogue Event component. Set the first element's Condition to require that the quest state is active. In this element, set the GameObject active.

    Set the second element's Condition to require that the quest state is success. In this element, set the GameObject inactive.
     
  9. schipman

    schipman

    Joined:
    Jan 22, 2010
    Posts:
    45
    Thanks for the quick reply- I will give that a go as a workaround for now :)
     
  10. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    @Darkkingdom - The tl;dr is: Put the Level Manager component on a child object of the Game Saver, not on the Game Saver itself. That should get everything working correctly.

    Sorry, I steered you wrong earlier by sending "LoadGame" and "SaveGame" directly to GameSaver. The problem is that LevelManager also has "LoadGame" and "SaveGame" methods. So when we sent "LoadGame" to the GameSaver GameObject, both scripts (GameSaver and LevelManager) tried to handle it, causing the level to load twice. If we'd continued with your "OnUse" method, it would have worked correctly. Anyway, by moving LevelManager to a child object, it won't try to also handle the "LoadGame" message that you really intended for GameSaver.

    Here's an updated example in which Level Manager is on a child object of Game Saver: GameSaverExample_2016-01-18.unitypackage

    If you notice any issues, please let me know. In the upcoming version of the Dialogue System, all existing functionality remains the same, but GameSaver and LevelManager log more useful information when the Dialogue Manager's Debug Level is set to Info. Also, GameSaver will find a LevelManager anywhere in the scene, so you don't need to add a LevelManager as a child object. Instead, you can just add a single LevelManager to the Dialogue Manager and never have to think about it again.
     
    Darkkingdom likes this.
  11. Darkkingdom

    Darkkingdom

    Joined:
    Sep 2, 2014
    Posts:
    81
    Ohhhhhh god it finally works!!!!!!!!!!
    Can't thank you enough for this^^
    It cost me and you nearly a whole week but now it works :)

    And no problem for the wrong driection^^
    I would recomend to link the example scene you made in your documentation.
    I think it will help many people, to set there savesystem up.
    Because it clearly shows the use of every component.
    And you can avoid another annoying user like me ;)

    My next step is to save my ints, floats, bool etc to the savegame.
    Hope I can solve it this time alone xD

    I'm looking forward to the next version :)
     
    Last edited: Jan 19, 2016
  12. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Sorry it took so long! I'm glad it's working now. Good idea about the example scene -- I'll link it in the documentation, as well as beefing up the documentation a bit.

    Saving ints/floats/bools is much easier. Just use DialogueLua.SetVariable() to store a variable value in the Dialogue System's environment and DialogueLua.GetVariable() to retrieve it. The Dialogue System's environment is included in all saved games.

    If you want this to happen automatically when saving and loading games, make a copy of PersistentDataTemplate.cs and put your code in it. Or just add OnRecordPersistentData() and OnApplyPersistentData() methods to any of your existing MonoBehaviour scripts. For example:

    Code (csharp):
    1. public class CharacterSheet : MonoBehaviour {
    2.  
    3.     public int level;
    4.     public float money;
    5.  
    6.     public void OnRecordPersistentData() {
    7.         DialogueLua.SetVariable("level", level);
    8.         DialogueLua.SetVariable("money", money);
    9.     }
    10.  
    11.     public void OnApplyPersistentData() {
    12.         level = DialogueLua.GetVariable("level").AsInt;
    13.         money = DialogueLua.GetVariable("money").AsFloat;
    14.     }
    15. }
     
    Last edited: Jan 20, 2016
    Darkkingdom likes this.
  13. Eitrius

    Eitrius

    Joined:
    Dec 30, 2013
    Posts:
    19
    Hi TonyLi, I was wondering what the best way to temporarily disable or hide the quest tracker HUD would be? I've tried disabling it, but when I re-enable it there is a default tracker entry above the active quest. I would prefer to do this in playmaker if possible, but scripting is fine too. Example below:

    "Quest Description"
    "Quest Entry Description"
    "Find the keys"​
     
  14. Darkkingdom

    Darkkingdom

    Joined:
    Sep 2, 2014
    Posts:
    81
    Okay after your great advice I'm almost done with my savesystem :)
    But I have one small question and I found the issue that made some of the problems before^^
    I noticed that the GameSaver didn't work corretly as long it is child of a Canvas.
    When it is a child, the level just loads without the saved data.

    Okay and now to my Question^^
    How do I save components like the SequenceTrigger?
    I want to save my "only once" bool^^
     
  15. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Hi @Mentalcase - Just deactivate and reactivate the quest tracker HUD GameObject. For example, if you've dropped the basic Dialogue Manager prefab into your scene, the GameObject is Dialogue Manager > Canvas > Generic Unity UI Quest Tracker HUD.

    If you're using legacy Unity GUI, disable the Quest Tracker component.

    If this doesn't work, or if you're using a different GUI system, please let me know the details.

    Hi @Darkkingdom - "Once Only" isn't persistent, so it isn't the best choice for that. Instead, define a variable in your dialogue database. Boolean variables work well for this. Set the Initial Value to False. In the trigger, set the Condition to require that the current value is False. When you fire the trigger, set the value to True. For a Sequence Trigger, use the SetVariable() sequencer command. For example:



    Since variables are automatically included in saved games, you don't need to do anything else.
     
  16. r3nrohan

    r3nrohan

    Joined:
    Sep 28, 2015
    Posts:
    33
    on using save system of dialouge system, how not to load the "destryoed" object
     
  17. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Hi @r3nrohan - Add a Persistent Destructible component to it.
     
  18. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    253
    Hello,

    Does Dialogue System support multi-scene setups? I'd like to have a "Managers" scene that's always loaded during play, and then load and unload various other scenes additively as the player visits different locations. Those locations have NPCs that you have dialogue with and data that needs saving, but the Managers scene also needs its data saved.

    I was thinking of putting the DialogueManager, with the "LevelManager" script, in the Managers scene but I read that it "records the player's current level" (http://www.pixelcrushers.com/dialogue_system/manual/html/save_system_persistent_data_components.html). Which level would it record in this case? Is it using the new SceneManager class or the old Application.loadedLevel (which does not take additive levels into account)? Are there any other problems with this idea?

    In case it's relevant: I'm also going to use Love/Hate, and would put its FactionManager in the Managers scene as well.
     
  19. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Hi @TommiH - A "Managers" scene is an ideal setup for the Dialogue System and Love/Hate. They both use a manager component (Dialogue Manager and Faction Manager, respectively) that's marked as Don't Destroy On Load.

    If you want to, you can also put a "test" Dialogue Manager in each of your gameplay scenes to make it easy to play that scene without having to come in from the Managers scene. When you do come in from the Manager scene, its Dialogue Manager will automatically destroy the "test" Dialogue Manager in the gameplay scene to ensure that there's only one instance.

    In Unity 5.3+, LevelManager and PersistentPositionData record SceneManager.GetActiveScene().name as the current level. When you load a game, it will load this scene. If you need to load multiple scenes, you can override or replace PersistentPositionData with your own code.
     
    hopeful likes this.
  20. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    253
    Thanks but I don't quite mean Don't Destroy On Load. I mean having the "Managers" scene itself loaded at all times.

    This sounds like it'll probably work fine with my design then.
     
  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    That's fine, too. Since the scene stays loaded, Don't Destroy On Load doesn't come into play.

    If you want to test it out with your design, please feel free to try the evaluation version.
     
  22. NioFox

    NioFox

    Joined:
    Dec 28, 2012
    Posts:
    65
    I'm getting some strange issue with Dialogue System v1.5.8 and Unity v5.3.1p3
    After I install the library and restart Unity the whole editor feels "sticky". For example, when I pan the scene view it causes big CPU spikes and feels laggy. Also, when I close Unity, the process gets stuck and I have to kill the .exe manually. I am not sure if this is a combination of the new version of unity or dialogue system, but I'd like to experiment with both.

    Is there any way to download older versions of Dialogue System?

    Update: Just downgraded to Unity 5.3.1f1 and still getting the issue.
     
    Last edited: Jan 21, 2016
  23. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Hi @NioFox - Yes, you can download them from the Pixel Crushers customer download site. If you need access, please PM me your Unity Asset Store invoice number.

    I suspect the "stickiness" culprit is unrelated to the Dialogue System. If you're not inspecting or editing a dialogue database, or using one of the setup wizards, the Dialogue System doesn't really do anything in the editor except for checking input in the Project view to handle double-clicks on dialogue database files.
     
  24. NioFox

    NioFox

    Joined:
    Dec 28, 2012
    Posts:
    65
    Looks like I already have the customer download link from a previous conversation we had, thanks.
    I found it strange that it is happening myself. I only came to the conclusion that it is something related to Dialogue Manager after stripping out everything else.

    Here are the steps took to recreate the problem (for me):
    1: Create new project (using 2D, not sure if that matters)
    2: Re-download Dialogue System from the Asset Store and imported it
    3: Close Unity
    4: Open Unity with the new project

    This is reproduce-able on my end. I'll try the older version now and see what happens.
     
  25. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    I'll test this, too. I haven't tested the Dialogue System with 5.3.1p3 yet. (BTW, testing with the 5.4 beta is on the slate for the next release of the Dialogue System, too.)
     
  26. NioFox

    NioFox

    Joined:
    Dec 28, 2012
    Posts:
    65
    I'm back to 5.3.1f1 now.
    The issue appears to exist with both new (1.5.8) and old (1.5.7a) versions of Dialogue System (for me)
    Is it possible to get anything older? I believe the last version I had working was a few versions back, but I can't remember the exact number. I do have a repository backup of my entire project but I want to avoid that if possible.
     
  27. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    It'll be a few hours (I'm out of the office at the moment), but I'll post here as soon as older versions are back online.
     
  28. NioFox

    NioFox

    Joined:
    Dec 28, 2012
    Posts:
    65
    Ok, I will try to make a clone of my project from just before I upgraded and see if the problem occurs.

    Update: Cancel that old version request. It does look as if the issue persists even with my backup. I suspect something else has gone awry with Unity, but I'm not sure what exactly :(
     
    Last edited: Jan 21, 2016
  29. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,682
    @NioFox - There are periodically bugs in Unity where the editor will take 100% CPU, and such. The most recent case I saw reported was for Linux editor users, but there have been other situations that can cause it. I'm not sure what the bug fix status is on all of those.
     
  30. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Hmm, perhaps it's an updated graphics driver conflict (the usual culprit), or an antivirus software issue? I saw that some users had issues with ASUS GamerOSD. If nothing else, you could check the editor.log file for errors. Or keep an eye on your OS system monitor for CPU spikes as @hopeful mentioned. Maybe they'll correspond to some specific Unity operation. Good luck!
     
  31. NioFox

    NioFox

    Joined:
    Dec 28, 2012
    Posts:
    65
    You are a life saver! It was this new version of EVGA Precision. Despite having told it NOT to run the OSD, it still caused Unity to do this weirdness. Thanks a tonne for that :)
     
  32. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Glad I could help! :)
     
  33. blaher

    blaher

    Joined:
    Oct 21, 2013
    Posts:
    80
    I'm sorting out workflow from articy:draft and using the importer. In articy the vertical order of dialog menu options is honored when using the presentation playback, but when imported into dialogue system, the menu options seem either last to first or maybe even random on some. How can I ensure the order of options the player has? For example:

    "Hello nice to meet you"
    "have you seen my dog"
    "goodbye for now"

    seems really odd when presented like:

    "goodbye for now"
    "have you seen my dog"
    "hello nice to meet you"
     
  34. blaher

    blaher

    Joined:
    Oct 21, 2013
    Posts:
    80
    also, is there a way to have dialogue options a player has already selected be grey'd out? either still selectable so they can go through it again if they choose to but so they know it is a live of questioning they have already been through?
     
  35. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Hi @blaher - In version 1.5.7+ of the Dialogue System, the order should be the same as articy's Presentation Mode, which goes by vertical order of the top of each dialogue fragment. Please check the version number in Assets/Dialogue System/_README.txt. If it's less than 1.5.7, update from the Asset Store. If you're using 1.5.7+ and options aren't in the same order as articy, please let me know. It's possible that something changed in some version of articy that the converter will need to accommodate.

    Yes. On your Dialogue Manager GameObject, change the Display Settings > Input Settings > Em Tag For Old Responses to something other than None. This will correspond to an emphasis setting (Em1 - Em4) in the dialogue database. You can define the appearance of emphasis settings by opening the dialogue database in the Dialogue Editor. On the Database tab, expand Emphasis Settings. Unfortunately there isn't an equivalent to emphasis tags in articy, so you'll have to define them here.
     
  36. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Dialogue System 1.5.8 Patch 2016-01-21 Available

    This patch is available on the Pixel Crushers customer download site. If you'd like access, please PM me your Unity Asset Store invoice number.

    This patch for version 1.5.8 includes:
    • Improved: GameSaver: If GameSaver doesn’t have a LevelManager as a child, it will search the scene for one.
    • Fixed: Trigger editors weren’t saving changes made to instances of prefabs in some versions of Unity.
    • Fixed: Dialogue Editor: Sync Actors didn’t sync alternate portrait images.
    • Unity UI: Removed duplicate typewriter effect from JRPG Dialogue UI prefab.
    • Realistic FPS Prefab: Additional handling during conversations prevents the VisibleBody component from animating the body, and it prevents CameraKick from bobbing the camera. To add the new functionality, select your FPSPlayer and then menu item Window > Dialogue System > Third Party > Realistic FPS Prefab > Disable Gameplay During Conversations.
    • RPG Kit: Made playerInventoryGameObjectName editable in RPGKitBridge; quest log window no longer hides cursor when closing by pressing Escape.
    • SALSA: Updated for SALSA 1.4, added support for RandomEyes shape groups.
    • Third Person Controller: Updated for Third Person Controller 1.2.
    These changes will also be in the upcoming 1.5.9 when it's released on the Asset Store.
     
  37. blaher

    blaher

    Joined:
    Oct 21, 2013
    Posts:
    80
    Thanks, I am using 1.5.8 and having out of order issue. Here is in-game and in articy (v2.3.8):
     

    Attached Files:

  38. Eitrius

    Eitrius

    Joined:
    Dec 30, 2013
    Posts:
    19
    I'm trying to add audio to the players lines, but I want them to have an option in their voice I have it set up like this: AudioWait(Player/[lua(Variable["PlayerAudio"])]/.....); This isn't working at all. Is it possible to do it like this or is there a different way to do it? Thank you
     
  39. Eitrius

    Eitrius

    Joined:
    Dec 30, 2013
    Posts:
    19
    Also, what is the syntax for using LipSync to do the same thing as AudioWait?
     
  40. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Ah, that's it. Ordering by dialogue fragment position is currently only implemented in the converter for articy:draft 2.4+. I'll backport it into 2.3.8 in the next release.

    Markup tags such as [lua(...)] don't work in sequences. What do you envision doing? Would entrytags help?

    The LipSync() sequencer command waits by default. The syntax is:

    LipSync(lipSyncData, [subject], [nowait])

    where lipSyncData is the name of a Rogo LipSync Data asset in a Resources folder. You have to prepare these assets ahead of time as normal in LipSync.

    The subject is optional and defaults to the current dialogue entry node's speaker. If subject is specified, the command will look for a GameObject whose name matches.

    If you include nowait as a third parameter, the sequencer command won't wait for Rogo LipSync to finish playing. This makes it act like Audio() instead of AudioWait().

    You can put your LipSync Data assets in subfolders inside Resources, such as:

    LipSync(LincolnSpeech/fourScore)
     
  41. Eitrius

    Eitrius

    Joined:
    Dec 30, 2013
    Posts:
    19
    We have two different voices recorded for all of the player dialogue. At the beginning of the game, the player selects which voice they want for their character. I looked at entrytags, and while I don't fully understand it, I don't know that that's what I'm looking for. I was trying to insert a variable into the file path for AudioWait so that it would be pointed to one of two folders with identical audio file names (which obviously doesn't work). What would you suggest doing in this situation?
     
  42. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    That's a smart idea. If it doesn't introduce any issues, I'll add this in the next release (coming out early next week).

    Another approach would be to put each voice pack in a separate asset bundle. When the player chooses a voice, load its asset bundle and call DialogueManager.RegisterAssetBundle() to let the Dialogue System use it for sequencer commands (see How To Use Asset Bundles). Other advantages of this are that you only load the specific voice pack you need, and you can add more voices as DLC without having to rebuild the project.
     
    Tinjaw and hopeful like this.
  43. Eitrius

    Eitrius

    Joined:
    Dec 30, 2013
    Posts:
    19
    That would be great! I will look into asset bundles more. Thank you!
     
  44. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    @Mentalcase - Sounds good! Also, thanks to your idea, [var=varName] and [lua(code)] tags are now supported in sequences as of the upcoming version 1.5.9!
     
  45. vivalavida

    vivalavida

    Joined:
    Feb 26, 2014
    Posts:
    85
    hi @TonyLi

    1: is there a way to get the conversation text entries?
    i want to display the dialogues on a separate text field but want to fetch them from the dialogue database based on entry number if possible.

    2: my character has two modes(we change the sprite sheet, but same gameobject), so would there be a way to get a different portrait image based on the mode..including expressions.
    A dialogue could have one of two portraits for each entry. would this be somehow possible?
     
    Last edited: Jan 29, 2016
  46. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Hi @vivalavida - Yes, see the DialogueDatabase API reference. If you want to access the Dialogue System's master database -- that is, the content of all currently-loaded databases -- use the property DialogueManager.MasterDatabase.

    A database contains a list of conversations. You can look up conversations by ID number or title.

    Each conversation has a list of dialogue entries. You can look up dialogue entries by ID number or title.

    For example, to fetch the text for dialogue entry 3 in the conversation "Sergeant Graves Barks", use this:

    Code (csharp):
    1. var entry = DialogueManager.MasterDatabase.GetConversation("Sergeant Graves Barks").GetDialogueEntry(3);
    2. var text = entry.DialogueText; // Or use entry.MenuText for the menu text.
    DialogueDatabase also has a shortcut method to get an entry with conversation and dialogue entry IDs. For example, to fetch the text for conversation 15, dialogue entry 42:

    Code (csharp):
    1. var entry = DialogueManager.MasterDatabase.GetDialogueEntry(15, 42);
    2. var text = entry.DialogueText;
    If you're doing this within an active conversation and you just want to get the current line's text, you can read DialogueManager.CurrentConversationState or add a script with an OnConversationLine method:

    Code (csharp):
    1. void OnConversationLine(Subtitle subtitle) {
    2.     var text = subtitle.formattedText.text;
    3. }
    Yes. Assign the portraits on the Dialogue Editor's Actors tab:



    Each portrait image will be assigned a number ([1], [2], [3], etc.). To maintain compatibility with existing projects, portraits are Texture2Ds, not sprites.

    To use a specific portrait image for a dialogue entry, include a [pic=#] tag in the Dialogue Text:

    Dialogue Text: "That makes me angry! [pic=3]"​

    To set a portrait image permanently, use the SetPortrait() sequencer command.

    If you're using sprites and/or animated portraits, you'll want to control the Animator Controller instead. If you'd like guidance on this, just let me know. You can refer to the Animated Sprite Portraits section of the documentation or examine the scene in Examples/Unity UI Examples/Animated Portraits.
     
    vivalavida likes this.
  47. kebrus

    kebrus

    Joined:
    Oct 10, 2011
    Posts:
    415
    Hi again TonyLi

    I'm trying to search in the documentation about randomization and I could only find the RandomElement function but doesn't fit my purpose. Is it possible to deliver multiple answer choices in a random order? or something like one answer is always at the same place and the others randomly ordered?
     
  48. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,688
    Hi @kebrus - To shuffle the order of responses, add a script with an OnConversationResponseMenu method to the Dialogue Manager. For example:

    Code (csharp):
    1. void OnConversationResponseMenu(Response[] responses) {
    2.     // Standard Fisher-Yates shuffle:
    3.     var n = responses.Length;
    4.     for (int i = 0; i < n; i++) {
    5.         var r = i + Random.Range(i, n - i);
    6.         Swap(responses[r], responses[i]);
    7.     }
    8. }
    9.  
    10. void Swap(Response a, Response b) {
    11.     var tempText = a.formattedText;
    12.     var tempEntry = a.destinationEntry;
    13.     var tempEnabled = a.enabled;
    14.     a.formattedText = b.formattedText;
    15.     a.destinationEntry = b.destinationEntry;
    16.     a.enabled = b.enabled;
    17.     b.formattedText = tempText;
    18.     b.destinationEntry = tempEntry;
    19.     b.enabled = tempEnabled;
    20. }
    This example shuffles all choices, but you could modify it to keep some answers in place.

    BTW, use RandomElement to insert random text, and the Conditions field to randomly decide whether to show a response or not. Neither are helpful to shuffle responses, but the example above should be useful for that.
     
  49. vivalavida

    vivalavida

    Joined:
    Feb 26, 2014
    Posts:
    85


    1: Awesome

    2: I'm able to change the sprites, but I want to get expressions based on what the default is.
    e.g., assume it to be a two player game, if character "A" goes over a "Door" the door would ask far a key and "A" would reply "I need to find the key" with portrait of "A" and expressions of "A".
    Same thing would happen if character "B" goes to the door. but now the portraits are that of "B" including expressions of "B". But the same dialogue chain.
    (in essence, change which 'actor' to use from the Actors tab of the database, but only the portrait images)
     
  50. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    Hello, I have put my island on the ocean but the problem how to put an ocean of sound that I heard only on the beach but not in the middle of the island ? Thank you