Search Unity

NPC Chat

Discussion in 'Assets and Asset Store' started by Stephen_O, Mar 1, 2014.

  1. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    NPC Chat is a powerful prefab and chat box system that allows you to quickly configure events, dialogue, notifications and more in a few quick steps.

    Simply add an NPC Chat object to your scene and assign the required inspector references (player transform, chat box to use, text, events and trigger settings).

    Version 1.9 requires Unity 2018.3.7 or higher.

    NPC Chat Promo.png
    Asset Store

    Many options are available to customize how you can use NPC Chat for different purposes.

    Chat Box Features:
    • Unity UI – the box is made from standard Unity UI components, simply edit or duplicate as needed if you want to customize the layout or design in any way for various needs.
    • Title and Dialogue Text – the basics of any dialogue system.
    • Dynamic Buttons – chat conversations can use up to 6 pre-configured buttons using the familiar inspector UnityEvent from the NPC Chat object when configuring page dialogue.
    • Render Texture Camera – allows for a speaker to be animated in a portrait window of the chat box.
    • Lerp In/Out Settings – the box can animate in-to and out-of screen space when a conversation starts or stops.

    NPC Chat Features:
    • Optimized Inspector Workflow – a clean inspector layout that provides quick access to all the settings you need.
    • Conversations and Pages – each NPC can have any number of conversations, each conversation can have any number of dialogue pages, each page can use any chat box.
    • Chat Manager – assign a Chat Manager ScriptableObject to control which NPC should use which conversation index.
    • NPC Chat Options – assign a NPC Chat Options ScriptableObject to control settings (start/stop triggers, input triggers, distance check, scrolling text, outline, single use, and more).
    • Page Audio – assign an audio clip to be played for a conversation page.
    • Page Buttons – chat conversations can use up to 6 pre-configured buttons using the familiar inspector UnityEvent. Set the button event and button text.
    • On Chat Start/Stop Events – setup conversation start/stop callback events using the familiar inspector UnityEvent. Trigger whatever you want to happen!
    • Outline – assign a mesh, skinned or sprite renderer to recieve outline effects based on NPC Chat states (distance, mouse over, active).
     
    Last edited: Jul 15, 2020
  2. biggsthecat

    biggsthecat

    Joined:
    Nov 1, 2013
    Posts:
    9
    Hey,

    I was looking for a suitable forum to ask some questions about this asset but this seemed the most fitting I could find. If I'm in the wrong area or whatever, let me know and I wont repost here or I'll keep my questions to the right area (still getting used to the site rules).

    I'm using this asset, it works fine in the demo scene, and although I have a platform input based character control setup, I modified a separate prefab of my character to use the third person controller and camera so I could interact with the dialogue triggers.

    In the demo scene, it works fine and my player will interact with the dialogue boxes, even before I removed the platform input setup for 3rd person it worked okay on some of them, but In my actual game my character refuses to interact with them. I tried modifying the 3rdpersonNPC script to be a platform input one, and added the extra functions and scripts to turn off when the dialogue was running but no joy. Any suggestions or just keep on tweaking?
     
  3. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    NPC Chat v1.7 now available!

    Added lots of custom editor features to make creating dialogue or message encounters faster and easier.
     
  4. Nateply

    Nateply

    Joined:
    May 20, 2014
    Posts:
    46
    Bought it, thanks! I'm working on a Unity 5 networking multiplayer setup. The player is being spawned using Network Manager, so is not in the scene initially. I have a test cylinder setup in the scene setup with NPC chat. I'm unable to get the NPC Chat Player Transform to work with the spawned player prefab (I do have it tagged as Player), partially. Once the spawned player approaches the NPC Chat zone, the distance to chat (where the sphere turns green) doesn't work. The chat trigger does for the chat itself, however. Everything works fine when I switch the triggerer to something that's in the scene initially. Do you have any suggestions on how to proceed with this spawned player/multiplayer issue?

    Edited.
     
    Last edited: Dec 27, 2015
  5. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    I'm not really sure, but it sounds like it is player collision related on your player object. My first question would be does your player object that's tagged player have a collider? A single collider on your player object with that tag is what initializes chat on collision. The network portion of your project should not make this function differently.

    If you would like you can contact me by email for support and also through skype with screen share for help debugging.
     
    Last edited: Dec 28, 2015
  6. jaizilla

    jaizilla

    Joined:
    Dec 24, 2015
    Posts:
    1
    Hi I'm new to unity and I'm looking at buying this pack but I needed to know first is this script able to work on a 2d box collider setup?

    I have nearly completed a basic demo of my JRPG style game and just looking for a asset pack that I can just drop into my game for on collision text and cinematic text boxes.

    Thanks
     
  7. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Hi,

    This should work just fine for 2D, a minor adjustment might need to be made for for the collider trigger check in the code. If you decide to buy send me an email if it doesn't work and I'll update the package and send back to you a working 2D demo scene.
     
  8. Slowbud

    Slowbud

    Joined:
    Jul 19, 2015
    Posts:
    81
    Hello, I need help. Even after watching the video
    "Creating Structured, Dynamic or Sequenced Dialogue" several times I can't figure out how to create a structured dialogue. The termini (whats the difference between "conversation, dialogue and chat pages?) is such confusing and your mouse is jumping too nervous over the screen in the video.
    What I can do is displaying a chatbox with text and bottoms. When clicking a bottom action happens (calling a script function). So far so good.
    What I want to do is: After clicking a buttom, action should happen, but additional a different text and buttoms should appear depending which bottom was clicked. So there should be a structured dialogue, depending on the choice of the player.

    EDIT: Ok, figured it out. Important is that there a Bottom Element "NPC Chat" with the parameter "NPCChat.StartConversation" so that the next conversation is shown automatically.

    But it might be interesting for others to describe the whole way. (In a structured video ;-) )

    NPC Chat is a great tool, but with lack of description.
     
    Last edited: Feb 10, 2016
  9. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Th
    Thanks for the feedback, it's very helpful to hear. I'll be focusing on NPC Chat updates very soon and plan to improve the editor and workflow to make configuring more complex dialogue easier and faster. If you need help at anytime you can email me for skype info and I will help you solve any problem you might face relating to using the asset.

    Let me know if you need any help with anything. I'll also redo the tutorials when I update the asset.
     
  10. chas02068909

    chas02068909

    Joined:
    Sep 23, 2013
    Posts:
    21
    Hello,
    I am a beginner.
    I want to know NPC Chat can add scripted buttons with the dialogue with dialog Bubbles. the player will evaluate the message communicated by NPC by pressing a button "For" or "Against".
    Thank you
     
  11. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Hello,

    Yes, NPC Chat can have up to 5 buttons on each dialogue page that can call different public methods from your scripts. There's a demo scene that let's the player do this with a computer terminal to open/close the door and turn on/off the fan, as well as have a conversation with an NPC that has multiple outcomes based on the players answer.
     
  12. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.71 submitted.
    • Added example script to demo scene to demonstrate how a player controller can be stopped when dialogue starts using the standard assets 3rd person character controller.
    • Added "Disable On Chat" array to inspector this array can be used to disable assigned components on chat start and enable them on chat finish.
    • Added "On Chat Event()" to the inspector, use this to configure custom events when chat starts.
    • Added "On Stop Chat Event()" to the inspector, use this to configure custom events when chat stops.
     
  13. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.72 submitted.
    • Added "Chat On Key Up" - assign any key to be used for entering and scrolling dialogue.
     
  14. DragonRider

    DragonRider

    Joined:
    Jul 19, 2012
    Posts:
    11
    NPC Chat has really grown a lot since I first discovered it. I'll try to play around with it again soon to see if it fits the needs for my project. :)
     
    Stephen_O likes this.
  15. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    I'd love to hear about your experience and anything you might want added to the asset. :)
     
  16. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.72 is now available.

    • Added "Chat On Key Up" to assign any key to be used for entering and scrolling dialogue.
     
  17. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.73 has been submitted.
    • Redesigned Inspector Interface
    • Improved Chat Manager (Scriptable Object) Inspector Interface
    • Added Chat Manager Editor Window
    • Created A Complete Tutorial Series
    • Added Inspector Hints Toggle
    With this release I feel the asset has matured to reach its potential; of course anything can always be better and I will continue to reiterate on my design to improve this asset based on more feedback and by adding any requested features, or implementing new design methods that make sense.
     
  18. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.74 is now available.
    • Added "Auto Find Player By Name" option to NPC Chat inspector. If a player is not assigned, NPC Chat will repeatedly search the scene for the named Transform.
     
  19. ramsicle

    ramsicle

    Joined:
    Sep 16, 2013
    Posts:
    6
    Is there a way to enable buttons when text has finished completely displaying in the chat box?
    So I want it disabled until the all text is displayed then I want the button to dynamically be enabled...
    I need this to prevent user from pressing the button to soon.
     
  20. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Not by default, I've added this option to the inspector and will update the package soon, send me an email and I'll forward the script changes to you.
     
    Last edited: Jul 22, 2019
  21. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.75
    • Added namespace to scripts
    • Added option to not use distance checking
    • Added option to not scroll page text
    • Added option to not progress or close chat on key or mouse up
    • Added option to enable chat box buttons after the dialogue has finished scrolling

    • Improved inspector layout and design.
    • Improved demo scene to have more examples of NPC Chat configurations.
    • Improved NPC Chat logic, clicking on an NPC object that is finished scrolling and displaying its last page will no longer restart that objects dialogue.

    • Removed Canvas component from chat box prefab, chat boxes will now spawn into the focused scene canvas.
    • Removed unnecessary standard assets to optimize and reduce file size of asset package.
    • Changed method of spawning NPC Chat objects and chat boxes. You can also select these options from the right mouse click menu list.
    > GameObject/UI/NPC Chat/NPC Chat Object
    > GameObject/UI/NPC Chat/Default Chat Box
     
  22. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.75 is now available.
     
  23. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.76 will have a new configurable "NPC Outline" feature based on the NPC's current state. You'll be able to quickly set an outline color and size for the following conditions:

    -Too far to interact with NPC
    -Close enough to interact with NPC
    -Interacting with NPC
    -Mouse-over NPC when close enough to interact with NPC
     
    Last edited: Mar 28, 2017
  24. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.77 is almost ready
    • Added Chat On Key Down option
    • Added RT-Voice (text-to-speech) integration for page dialogue. Functionality not available for all platforms, see RT-Voice product description for more details. RT-Voice is a separate asset available here: RT-Voice
    • Added ResetChatManager script, add this to any object in a scene to reset the chat manager scriptable object index values to 0 when a scene loads. This may be useful depending on how you use NPC Chat.
     
    Last edited: Jul 22, 2019
  25. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.77 is now available!
     
  26. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.78 is now available.
    • Added 2nd tutorial scene for creating seamless, structured and dynamic dialogue sequences.
     
  27. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.79 submitted.
    • Added 2D support
    • Added 2D demo
     
    Last edited: Jul 22, 2019
  28. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.79 is now available!
     
  29. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    Quick question: Does this asset use ordinary text input, or a scripting language like Lua?
     
  30. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    NPC Chat text is entered through the inspector in standard text fields. No custom formatting is required or used.

    You can use Unity's built-in text styling https://docs.unity3d.com/Manual/StyledText.html
     
    Last edited: Jan 5, 2017
  31. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    Thank you for the prompt response. I don't need the rich text right now. I'm working on a prototype and keeping things simple.

    Can I set up conditional dialogue that will not trigger unless some bolean condition is set, for instance, dialogue that only plays when my character is a certain level?

    Either way, I will probably purchase NPC chat today. I think I will handle quest chat through a separate quest asset that integrates with my inventory system, but run all general purpose chat through NPC Chat. I may use RT Voice, which I see works with NPC Chat, and I like the simplicity of operation of NPC Chat, and your dedication to upgrading your assets and what appears to be superior support.
     
    Stephen_O likes this.
  32. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    NPC Chat is based on a single component, this component can hold many conversations and they are accessed by setting the conversation index number that you want used then next time chat starts.

    This type of structure will allow you to create multiple NPC Chat configurations as prefabs, and have them loaded into your scenes as needed, for example your NPC may use one prefab with a set of dialogues up to a specific level, then you can have a custom script check the player level and swap out the prefab based on your conditions.

    There is also a basic chat manager that is used to set conversation indexes for the NPC Chat components in the scene, you can build logic into this or have your logic call the functions in the chat manager to control a NPCs conversation index.
     
    wood333 likes this.
  33. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    @wood333 It turns out rich text markup is already supported, I was hastily testing it wrong! Here's a sample of text markup using the inspector text field. This works fine for text that does not scroll, I will need to make an update for this to work with text as it scrolls in.

    https://docs.unity3d.com/Manual/StyledText.html
     

    Attached Files:

    Last edited: Jan 5, 2017
    wood333 likes this.
  34. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    Thanks again for the prompt response. I purchased.
     
    Stephen_O likes this.
  35. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    You're welcome and thank you! Let me know if you need anything, I'll try to get the Rich Text Formatting setup for scrolling text by end of day, if not it will be ready soon.
     
    wood333 likes this.
  36. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Last edited: Jul 22, 2019
    wood333 likes this.
  37. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    Beautiful! And a great explanatory video to boot!
     
  38. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.8 submitted.
    • Added a function to support parsing live typed text into the UI Chat box to create a new formatted string that supports Unity Rich/Styled Text markup tags: https://docs.unity3d.com/Manual/StyledText.html .
    • Rich/Styled Text supports RT-Voice by parsing the marked up text to output a plain text string that gets passed to the RT-Voice speaker.
     
    wood333 likes this.
  39. misterlee

    misterlee

    Joined:
    Sep 19, 2014
    Posts:
    54
    I can see it's possible to have multiple pieces of text stored in the NPC Chat (conversation pages) but what I can't see is how to trigger a specific one. I don't want them to just run in order. My character has various things to say about multiple different objects throughout the level that may or may not be interacted with so the 'chat' can't run in order because the player won't get to them in order. How can I specify which 'conversation' gets triggered, if that's even possible?

    Of course I could just set up lots of single 'conversation' chat UI boxes and have which ever one I needed triggered when I get to it, but that means tons of unnecessary UI game objects and potential for inconsistent formatting when I just want different text from the same character.

    Also, I'm using PlayMaker so if there is something specific that relates to that please let me know.
     
    Stephen_O likes this.
  40. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    You can handle this scenario with a single NPC Chat object:
    1. You would want to create a conversation for each encounter this NPC should have, we will call this NPC "NPC 0".
    2. Make a reference to the chat manager object some place in your project, you will use this object to change the conversation index of "NPC 0". I attached a screenshot.
    3. Then you will want to set the chat manager conversation index for "NPC 0" to the appropriate conversation index you would like to use.
    So if your NPC needs to use conversation 3's dialogue, then you would send a message to the chat manager that will set the conversation index to 3. You can do this for as many NPC's as you like, just create a unique NPC index slot for each of your NPCs. The NPC Chat object's inspector has a field to indicate which NPC Number it will use.

    I know you're using playmaker but you can also call public methods on the scriptable object to change the chat index from code, once you have a reference you can call:
    Code (CSharp):
    1. public void ChangeTarget( int newNPC){
    2.         targetNPC = newNPC;
    3. }
    4.      
    5. public void NewDialogue( int newDialogue ){
    6.        currentDialogue[targetNPC] = newDialogue;
    7. }
    You would want to call
    Code (CSharp):
    1. ChangeTarget(npcNumber)
    followed by
    Code (CSharp):
    1. NewDialogue(conversationNumber)
     

    Attached Files:

    misterlee likes this.
  41. misterlee

    misterlee

    Joined:
    Sep 19, 2014
    Posts:
    54
    Thanks very much for the reply and explanation.
    Ordinarily it would be simple enough to send an int value to another script using Send Message. The problem is that the chat manager isn't a game object in the scene, it's just sat in the assets folder for some reason, so it doesn't seem possible to use the Send Message action I'd usually use to interact with a script on a regular game object in the scene.

    Do you know how to do that?

    I don't really understand why the chat manager is not in the scene and considered a game object since it is an object and in the game... but there you go o_O
     
    Stephen_O likes this.
  42. misterlee

    misterlee

    Joined:
    Sep 19, 2014
    Posts:
    54
    I tried making a script instead of using PlayMaker too, but the code you posted above didn't work for me :(
    I get two errors:

    Assets/Scripts/UpdateNPCConversationScript.cs(12,3): error CS0103: The name `targetNPC' does not exist in the current context

    Assets/Scripts/UpdateNPCConversationScript.cs(16,3): error CS0103: The name `currentDialogue' does not exist in the current context
     
  43. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    You can still make reference to a scriptable object if it's not in your scene, The benefit of scriptable objects is that they do not need to be in a scene and can be referenced from any scene or script; there is only one object to manage.

    If you follow the structured dialogue tutorial I work with the Chat Manager, explain how it works and also write an example script using it. The demo scene NPCs make use of the Chat Manager for structured dialogue as well through the NPC Chat inspector by making an inspector reference to it in the project folder.

    If you want to use the chat manager as a scene object you can use this script, add it to a game object and call the ChangeTarget() and NewDialogue() methods to modify the chat manager.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using TurnTheGameOn.NPCChat;
    4.  
    5. public class SceneChatManager : MonoBehaviour {
    6.  
    7.     public ChatManager chatManager;
    8.  
    9.     void Start () {
    10.         if(chatManager == null)    chatManager = Resources.Load ("ChatManager") as ChatManager;
    11.     }
    12.  
    13.     public void ChangeTarget( int newNPC){
    14.         chatManager.targetNPC = newNPC;
    15.     }
    16.  
    17.     public void NewDialogue( int newDialogue ){
    18.         chatManager.currentDialogue[chatManager.targetNPC] = newDialogue;
    19.     }
    20.  
    21. }
     

    Attached Files:

    Last edited: Jul 22, 2019
  44. misterlee

    misterlee

    Joined:
    Sep 19, 2014
    Posts:
    54
    Again thanks VERY much for the reply and help. My script was almost the same as your but without the 'using TurnTheGameOn.NPCChat;' bit at the top which seems to be the magic line to make it work :)

    I've also discovered what scriptable objects are now, so that's good to know!

    It's taken a while to get it all working, but I think it's all done now. Basically I'm using PlayMakers 'Send Event' action to send the int value for 'ChangeTarget' and 'NewDialogue' to the scene chat script (on a game object in my scene), which updates the chat manager. And hey presto it works and I can trigger my character to say whatever line of dialogue I want, whenever I want. Cool :)

    I noticed there are options for closing the chat with mouse and keyboard, but there doesn't seem to be an option for gamepad button presses? I've done it myself with PlayMaker actions so it's fine but maybe that's a useful option too?
     
    Stephen_O likes this.
  45. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    That's great, I'm glad you got everything set up and working properly. I'll add a demo scene to the next update that includes the script to access the Chat Manager from a scene object. I will also add an option for Joystick Input button selection, that's a good suggestion thanks for it!
     
  46. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.8 is now available.
    • Added a function to support parsing live typed text into the UI Chat box to create a new formatted string that supports Unity Rich/Styled Text markup tags: https://docs.unity3d.com/Manual/StyledText.html .
    • Rich/Styled Text supports RT-Voice by parsing the marked up text to output a plain text string that gets passed to the RT-Voice speaker.
     
  47. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Version 1.81 submitted.
    • Added "Chat On Joystick Button Up" to inspector.
    • Added "Chat On Joystick Button Down" to inspector.
    • Added SceneChatManager.cs script. Add this script to a game object in your scene if you would like to control the chat manager from a scene object using this script as an interface, this may be useful in some cases.
     
  48. AcePhilips85

    AcePhilips85

    Joined:
    Mar 18, 2016
    Posts:
    20
    Hello! i'm a bit stumped here and was wondering if you could help me. I have an error that says

    Index out of range exception: Array index is out of range
    TurnTheGameOn.NPCChat.NPCChat.Awake () at assets/TurnTheGameOn/NPC Chat/Scripts/NPCChat.cs:196

    and the other one I get says
    TurnTheGameOn.NPCChat.NPCChat.Awake () at assets/TurnTheGameOn/NPC Chat/Scripts/NPCChat.cs:413


    I have no idea what I have done wrong, and I have not changed any line of code. Please help? Thank you for your time.
     
    Stephen_O likes this.
  49. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Hi, it sounds like your NPC conversation index is not set to the right value in the "Chat Manager", check to make sure it's set to 0 so the NPC uses the first conversation it has configured.
     

    Attached Files:

  50. AcePhilips85

    AcePhilips85

    Joined:
    Mar 18, 2016
    Posts:
    20
    Thank you! this worked out for me. I think I can work my way through the rest. This is a great dialogue solution or my game! Your hard work is appreciated.
     
    Stephen_O likes this.