A dialogue trigger communicates messages to the player when they enter the area.
- Setup a project and scripts folder
- In Project, Create a new folder
- Name it _PROJECT and hit return
- Create a new folder inside _PROJECT
- Name it Scripts and hit return
- Create a script
- In Scripts, right-click and Create C# Script
- Name it Dialogue and hit return
- Past the code in and save it http://pastebin.com/C4em8twF
- Create the text
- Create UI / Text
- Rename it MessageText
- Create a trigger
- Create 3d Object / Cube
- Make its collider a trigger
- Rename it dialogue trigger
- Drag Dialogue script onto it or Add Component / Dialogue
- Type a message into the Message variable input box in the inspector
- Test it by hitting play and entering the cube to see the message appear
- If it works, click the dialogue trigger cube
- Uncheck the box for its Renderer to disable it and hide it.
Place it where you want it, you can turn its renderer on when you’re repositioning it to see it better.
This dialogue is very simple as it doesn’t give the player the ability to respond or have multiple lines of dialogue. For that, it is better to use a dialogue framework:
- Dialogue Generator
- Fungus with FungusTrigger
- Dialogue System
Dialogue Generator is a free and open-source more advanced C# script that adds multiple choices. It lacks a flowchart authoring mode, which Fungus has, but it has the advantage of being native C# script.
Fungus is a free and open-source dialogue and narrative system for Unity that includes a flowchart authoring environment, a rich scripting system of visual blocks that require no C# knowledge, Lua scripting with variables, and a wide variety of example scenes demonstrating visual novel-style games.
FungusTrigger is a script that will let you use Fungus in combination with your 2D or 3D game’s character exploring the world.
Dialogue System is the full-blown way to create professional game dialogue. It is best used in combination with Articy Draft.
Articy Draft is a narrative design tool that now has a Unity plugin to bring dialogue and point-and-click adventure location navigation directly into Unity as playable scenes.