RPGTalk

1.Introduction


RPGTalk is a simple plugin for Unity3D that allows the creation of dialogs like the classics of the RPG genre. The text is shown smoothly and totally customisable.

The great advantage of it is that it has several options already on Script that open a lot of possibilities in each speech. Besides, it reads the dialog from a text file, allowing the change of speech without any extra code, besides make it very easy to work with localisation for other languages or dubbing.

Check the video demo!

1.1.What's new?

Version 1.3:

  • Talks can pass themselves
  • TextUI now accepts Text Mesh Pro classes
  • Language is easier to set
  • Characters now can be set differently, and have its own expressions or animators.
  • Follow character now is a snippet
  • The “Can pass” signal is now a snippet
  • We have a smart pointer, a snippet for Line Renderers pointers.
  • Save Instance snippet, making it easier to change dialog based on saved conversations
  • NewTalk tag, making it easier to change the dialog midway
  • Jitter tag for TMP, making part of the text jitter!
  • BETA: Node Editor! Visually change your TXTs instead of writing it outside Unity.

Note: Every time that you update a Plugin, backup your project.
A lot has changed in RPGTalk base on this update to accept TMP.
You can loose your TextUI and DialogerUI references.
The way the Dialog Window follow a character has also changed, you will need to revision it.
Localisation have changed so it have to be set on an Asset.
The Callback on RPGTalkHolder is now a UnityEvent. You will loose your previous references.

Version 1.2:

  • Rich Text is now officially supported, even if the beggining and the end tag are separated by different lines;
  • Now is possible to place sprites inside the text, occupying space as if it were a character in the text;
  • You can change the speed of the text while the talk is running;
  • Timeline ready;
  • Localization inside RPGTalk or any UI Text;
  • Easier to change Target Follow during the talk;
  • RPGTalk Area to change the text or interact with a character without any code;
  • Line To Start and Line To Break can now be titles instead of fixed line numbers;
  • The player can now make choices in the text;
  • Dubbing is possible in every line and fully integrated with Localization.

Note: Every time that you update a Plugin, backup your project. In this update of RPGTalk you shouldn’t have much trouble, but you can loose your references to the targetFollow variable.

1.2.Download

RPGTalk is available for free in the  Unity Asset Store, the specialized store of authorized packages for Unity3D. You can get it Clicking Here!

1.3.Contribute

RPGTalk is pretty good, but it has quite room for improvement.

Why don’t we make it better together?

RPGTalk is opensource and hosted on GitHub. If you have made modifications or snippets for your game, share with the community! Fork it, make a pull request! Let’s create an awesome asset!

2.Tutorials

Although it has several options, the implementation of RPGTalk is very simple. Basically, you just need a Text File, a Canvas ready and the RPGTalk Component. In this section, you will learn step-by-step with details each implementation, but be sure to check the demo scenes included on the package.

2.1.Quick Start

rpgtlkAfter the package is  imported, you should see a configuration file. This configuration can be set anytime by going to the menu RPGTalk > Configure.
It is pretty simple, basically, ask if you are using TextMeshPro and make sure you understand how Encoding works.

All set? All set! Now you just have to prepare three steps to make RPGTalk ready to go:

1. Text File
textpt1
RPGTalk reads the dialogs of a text file with the .TXT extension. Use your favorite editor (Notepad, TextEdit, etc) to create that sort of file. Save it inside the folder Assets of your Unity project.

Important: each new line will be a new dialog box. Do not be afraid of making a big line with everything you want to stay in the same dialog. For default, RPTalk break the text automatically into new dialog boxes with the option Word Wrap.

2. Canvas

Using the functions of the Unity itself to show your dialogs, RPGTalk uses a Canvas, allowing every single one of its configurations. To start off, it just needs a Text.

Inside the Unity’s scene, create a Canvas in Game Object > UI > Canvas. After that, create a Text in Game Object > UI > Text. If you prefer, you can use TextMeshPro, creating it instead in Game Object > UI > TextMeshPro – Text.

You can configure the Canvas and Text the way you like it. Just have in mind that the initial text will be overwritten by whatever there is in the Text File you created in the previous step.

canvaspt1

3. RPGTalk Component
inspectorpt1
Finally, you need to add the RPGTalk component in any scene object (Add Component > Seize Studios > RPGTalk > RPGTalk). You can also create a new RPGTalk by the top menu RPGTalk > Create RPGTalk > Base Instance.

The component will be shown in the Inspector and it has a lot of options, but for the quick start, we only nee to focus on three.

The first option asks for a TextAsset file. Put the file we created on the step 1 there!

While we are at it, why don’t we say the line that the Talk Should Start & End?: At default, the value of Line To Start is 1 and Line to Break -1. That means that the dialog will start reading the Text File by the first line, and it will only stop and it reaches the end of it. But you can choose any value for the start and the end, meaning you can set several dialogs with the same TXT.
These values can also be a string, a title to look for in the TXT file instead of setting the exact line number. To do so, a change in the text is needed:
If you write cutscene1_start in the Line To Start variable and cutscene1_end in the Line To Break, your text should look like this:

[title=cutscene1_start]
This line will be shown!
This will too! Awesome!
[title=cutscene1_end]
This won't.

This is just another way of using the TXT file. If you want to read it all, leave at is.
Right below, we have the “Show With Dialog” option. That is an Array that you can set any element that should appear when the dialog starts and disappear when it ends. Usually, that Array has at least 1 object: the Canvas that we created on step 2.
More below, inside the options on Interface, RPGTalk asks who is the “Text UI”. There, you should place the Text we created on step 2.

All set! If everything is fine, you can hit Play and see the dialog happen! Pass it clicking on the screen!

quickstart

Congratulations, you learned the base of RPGTalk and already can create dialogs! But there are a lot of useful options that can help you! Keep reading to see every one of them!

2.2.Regular Options

regularoptions

Here you will find basic options of RPGTalk that changes how it shows the dialog on the screen. Let’s see each one of them:

Start On Awake?
If that option is marked, the dialog initiates when the object calls the function Start (usually, in the beginning of the scene).
Should try to read the name of the talker?
RPGTalk can try to read the name of who is talking. With that option marked, it becomes visible, in the Interface Options, the Dialoger UI. It also makes possible to have a whole lot of more options, opening the Characters Settings tab. Note also that is necessary a change in the text so that the name can be shown correctly. In the Text File, you should have each line start with the name of the Talker, followed by “:” and then the dialog itself. For instance:

HeroName: I'm going to save the world!

Should there be the photo of the talker?
This option unlock the options UI Photo in Interface, replacing that UI by the sprite set on the Character. See more in each section.
Should the canvas stay on screen after the talk ended?
If that option is checked, every object in the “Show With Dialog” Array keep itself in the screen even after the dialog has finished.
Enable QuickStep?
If checked, the player can skip the text without waiting for the end of the animation.
Text Speed
The speed that the text animation should play, in character per second. The speed can also be changed during the talk (see: Tags.)
Pass the Talk with mouse click?
If checked, a simple click on the screen is enough to pass the dialog.
Pass with Button
Right below the Mouse option, you can write any Input (set on em Project Settings > Input) that also can be used to pass the dialog. That is useful if you want any key or Joystick button working besides the mouse.
The talk can also be passed with some key
Well… That one is self explanatory… Choose a key that will also pass the talk.
Automatically Pass the Talk?
You may want you talk to pass itself, without having the need of the player to press anything. If set, it will open the option Seconds Auto Pass, that says the seconds after the text stopped animating that the talk will be passed on its own.
Word Wrap?
If true, it will open the options Max Char Width and Max Char Height. You should put in them the maximum characters, in length and height, that fit in your Dialog Box. That will allow RPGTalk to automatically cut the text into several dialogs, that way you don’t have to worry about the size of a line in the Text File.

2.3.Characters Settings

rpgtlk2This whole option group will only be visible if you have set Should try to read the name of the talker option on the Regular Options.

The first option, Should the canvas follow someone, opens a new option in every character, that you should set a Transform to follow and an offset.
Note that to actually follow someone, your RPGTalk object should also have the Follow Character snippet.

The only other thing on this group are Characters. Click the + button to add a character to the list. This list should have the characters that will participate in this conversation (or this whole scene, depending on how you are setting your talks).

The first thing it asks of you is Who is this character? This needs to be created on your project. See more down below.
If you press the button just beside it, the character will be removed from the list.

Then, you have the Should a different Animator be set for it option. RPGTalk can communicate with an Animator (See more in the Animation group). But if this option is marked, instead of communicating with the Animator set on the Animation group, it will communicate with the animator set here when this character is talking.
Useful when you want your characters on screen to animate instead of something like a photo alongside the UI.

Creating a character

To use those options, you will need to create a character. This character is stored in your project, and can be reused on several scenes and/or talks.

rpgtlk3To create one, go to the Project window, Right Click and the desired folder and go Create > RPGTalk > Character.

The options here are quite simple.
Who is the Dialoger? What is name, as written on the TXT, that this character represents?

What Photo this character have? If any is set, the UIPhoto on the Interface Options will be this sprite when this character is saying something.

Additionally, you can set any number of Expressions to this character.

An expression can have a Name, the one it will look for on the TXT (see more in the Tags section).
A Photo to be set in UIPhoto if this expression is being used.
A Bool in Animator that will be true while a line with that expression is being said.
And an Audio that will play every time this expression comes around.

2.4.Interface

interfaceHere you find the interface options.

Text UI: That parameter is a mandatory and should be set with the Text object that RPGTalk should write on.
Dialoger UI: This parameter should be set with the Text Object that the RPGTalk should fill with the name of who is talking that dialog. Note: this parameter is only available if the option “Should show the name of the talker?” in Regular Options is checked.
UI Photo: This parameter should be set with the Image object that the RPGTalk should change with the photo of who is talking the dialog. Note: this parameter is only available if the options “Should there be the photo of the talker?”  in Regular Options is checked.

2.5.Callback, Breaks & Variables

rpgtlk4In this section, you can change configurations about Scripts and how RPGTalk should act outside the standard.

Any script should be called when the Talk is done?
You can click the + and choose any number of objects and methods to be called when the talk ends. Note that it follows the rules of UnityEvents, so the method should be public and have, at most, one parameter.

Variables: Right away, you can give a value in an Array that will be the variables that exists in the Text. For each element in the Array, you will see more two options:

Variable Name: The name of the variable, the exactly same way that is written on the Text File, to be replaced.
Variable Value: The value that should replace the variable on the above parameter.

Note: This is a simple way of doing events. If you need more control and know a little bit of coding, go the Events.

2.6.Photos and Sprites

Screen Shot 2017-09-25 at 14.43.21In this section you can set sprites to be added as UI Images inside the text.

Sprites: You can set here any sprites that can be showed in the text. Note the number of the array element and use it in your TXT to place the sprite in the correct position. For instance, to show the sprite that you created here as the Element 1, in your text, you should write the line like this:

Well, I want to have a sprite right here [sprite=1] before these words.

For each element created in this array, you have the following options:

Sprite: The sprite itself that will be shown i the text.
Width/Height: The size that the sprite will have in characters. If you set the width and height as 1, the image will have the same size as a letter inside of your text. The size varies depending on the font and font-size parameters in the text.
Animator: if you want this sprite to be animated, you can set here a Animator that will be created with it.

sprites in the text

Note: If you are using TextMeshPro, instead of this options will be requested a Tmp Sprite Atlas, that you should refer to TextMeshPro to learn how to use it right.

2.7.Animation

animation

Here, you will find the options of animation. They are simple but allows you to make anything necessary to a complete dialog.

Animator: Set here a Animator Object that should treat the animations.
Boolean Name: Write the name of a Boolean parameter that exists in Animator. That parameter will be set to true when the Text animation is running.
Int Name: Write the name of an Integer parameter that exists in Animator. This parameter will have the value of the character who is talking, starting by zero. The number that represents each character is the order that they are set in the parameter in the Character Settings.

2.8.Audio

audioHere, you will find the Audio options. They are only two that create the environment of true RPG dialog:

Letter Sound: You can set a Audio file to play while the letters are running. The audio will stop when it ends.
Click Sound: Each time that the player passes a dialog, RPGTalk can play the sound file that you put here.

Note: This shouldn’t be used for voice-overs. To do that, see Dubbing.

2.9.Choices

choicesIf you want your player to have the ability to make choices in the game, this is the place to go.

Choice Prefab: Here you set a prefab to be instantiated when a question is made by the text. This prefab preferably follows the base button structure of Unity’s canvas: An object with the Button component and its child with a Text component.
Choices Parent: You can set an object to be the parent of the buttons that will be instantiated when a question is made. The best practice is to choose here an object with a “Canvas Layout Group” component, so the buttons will be aligned automatically.

choices

To make the question and choices happen, you need to set them in your TXT. The question must have an ID so you can track the answer later, so use the [question=X]  tag when asking a question and in the following lines start with the [choice] tag. Your text should look like this:

TalkerName: [question=0]So, can I ask you something?
[choice]Sure!
[choice]I'm not im the mood.
TalkerName: Text to be shown after the answer

Each time a answer is given, an event is called so you can track it and change the text or save the answer for something else in your game. Check Events to see more.

TIP: If you want to easily save the Answer given, look for the Save Instance Snippet.
TIP2: If you want to change the conversation depending on what the player chose, look for the NewTalk Tag!

2.10.Easily changing the text while the game is running

Every option in the inspector is public, so you can change it by script anytime you want. But since version 1.2, RPGTalk have a new component called RPGTalk Area, that helps you change the talks without writing any code.

You can create a RPGTalk Area object by going into the top menu and selecting RPGTalk > Create RPGTalk Area.
You can also place the component in any object (Add Component > Seize Studios > RPGTalk > RPGTalk Area), just note that it needs a collider to work. It can be 2D or 3D, as long as it is a trigger.

What RPGTalk Area does is to change some parameters when colliding with a trigger. Feel free to change the collider’s size to fit your needs.

area

In the first parameter, choose the RPGTalk instance that you want to change.
Just below, you can set a Playable Director so that this area will instead (or also) play a Timeline.

The next set of parameter is about when the stuff should happen.
Should wait for user’s interaction to start?
If marked as true, nothing will happen until the player interacts with this area. You will be asked what key is need to be pressed so the interaction begins. Also, you can set a lot of GameObjects to be shown when interaction is possible. A good practice is to place some canvas with the text “Press A to talk”.

If marked as false, you will have to tell RPGTalk Area when it should start. When the user enters this trigger? Or when it leaves? Or both?

Can only be played once? must be marked if you do not want this conversation to happen again if the player interacts with this area.
Cannot be played if the RPGTalk instance is already playing forbids the Area to work if there is another talk running in this RPGTalk instance.
You can also write a tag below to check who can interact with this area. If you write “Player”, for instance, only objects with the tag Player will be able to activate this area.

The next section brings you Callback options, similar to how they work in the Callbacks & Variables section. The difference here is that you can call a function in a script before the Area activates.
A common use is to block player’s controls while someone is talking, but giving it back once the talk is over.

In the next section you can set another TextAsset (TXT) to be read and say the lines to begin and break, just like you would do in the main instance of RPGTalk.
You can also set if this talk is supposed to pass itself, and if so, how many seconds it will wait. Similar to the Regular Options.
Right after, you can choose if the dialog should stay in the screen.

Note that these changes will be kept in the RPGTalk instance even when the player leaves the Area.

NOTE: If you mark Can only be played once, another option called Saved if this area has already played is shown. This option is useful if you don’t want the area to play again if the player change scenes or closes the game and open it again. But to work right, the RPGTalk instance need to have the Save Instance snippet.

2.11.Dubbing

RPGTalk can easily play Dubbing or any sound with the talk. It is fully integrated with RPGTalk Localization so you can have different sounds for different languages as well.
Dubbing
The first thing you need to do is add the RPGTalk Dub Sounds component to the same object that has the RPGTalk instance.
Once this done, you have the array Dubs By Language and need to set here how many languages you will have the dubbing into.

For each element created, you will have the Language option (if you will not use RPGTalk Localization, you can ignore this setting) and the Dub Clip array. All you need to do is set in this array all sounds that you might want to play with the text. Take note of the element number of each one of them.

Finally, in your text, you need to call the dubbing by its ID. Just like that:

TalkerName: [dub=0] Wow! This line will play the first sound!
TalkerName: [dub=1] Yeah! And this will play the second!
TalkerName: Humm... This will play no dubbing sound...

Note that when a dialog is passed, the sound of the ancient one is stopped, even if the new one doesn’t have a dub. So when the player skips the conversation without waiting for the sound to finish, it will be clamped.

Finally you have the option to Use an Audio Mixer so you can control better your sound options.

2.12.Localization

RPGTalk can handle the localization of your game for you, but it does not translate the text automatically. You need to have one copy of your text file (or files) for each language.
If you set RPGTalk to start and break with the line number, make sure all the text files have the same line at the same number.
If you set it to look for the tag title (see more in Tags) make sure you have the corresponding titles in every text file.
Something like this in the file Cutscene1_English.txt :

First line in the talk, awesome!
Second is good.
[title=MyTitle]
This is good.
This line doesn't exists in the portuguese language, but its fine because I used titles.
[title=MyTitle_End]

And its corresponding file Cutscene1_Portuguese.txt :

Primeira linha no diálogo, legal!
Segunda é bom.
[title=MyTitle]
Isso é bom.
[title=MyTitle_End]

With your texts ready, you need an instance of RPGTalk Localization in your scene. You can create it by going in the top menu RPGTalk > Create RPGTalk Localization or adding it as a component to any object.

IMPORTANT: RPGTalk Localization doesn’t get destroyed when the scene unloads, since you hardly need to change it between scenes. But it works by iterating between all the text files, so if your game is too big, you might want to destroy it yourself and create other for specific scenes/places to not risk frame drops every time you have a new talk.

rpgtlk5Once the component is ready, you only need to add to the array the number of languages that your game will support.
For each element created, you should add the Language file. Language files are created on your project. See more below.

If in playmode, you can see some debug information like what is the default language and what language is the player currently in.

Creating a Language

In your project, you should Right Click on a folder and go to Create > RPGTalk > Language.
The new created file have some options.

First, what is the identifier of this language? It usually is a code like “EN_US”, “PT_BR”, “FR”, “EN”, etc.
After that, you will have the option to make this language your Main Language. Now sober up! This is important.

IMPORTANT:
The Main Language of your game is more than the language that your game will start with.
Every TXT file set in your scenes should be on the Main Language.

The only other option here is your TXT files.
If this is your Main Language, you will have to say how many TXT files are there in your game and what they are (in your main Language).

If this is not your Main Language, you will see a list of TXT files that you previously set in your Main Language and you will be asked what are the equivalent TXTs in that language you are currently on.

For Instance: In English, my Main Language, I have set: “Cutscene_0_English.txt” and “Cutscene_1_English.txt”.
In Portuguese, other Language my game accepts, I have said that the equivalent of “Cutscene_0_English.txt” is my other file, “Cutscene_0_Portuguese.txt”, and so on.

 

 

Phew! This is it! If you need to change the current language in gameplay you can do it simply calling:

LanguageSettings.actualLanguage

Note that you need to call the correct library in your code. For instance, a code that changes the language to EN_US when the game starts would be:

using UnityEngine;
using RPGTALK.Localization;



public class MyClass : MonoBehaviour{
void Start(){
LanguageSettings.actualLanguage = SupportedLanguages.EN_US;
}
}

 

Ok, RPGTalk is awesome, but you don’t use it for e-v-e-r-y text in your game, right? Like the main menu or other interface itens. You can still lay your back on RPGTalk Localization if you use the default UI Text.

Simply add the component RPGTalk Localization String (Add Component > Seize Studios > RPGTalk > Localization > RPGTalk Localization String) to any object that has a Text component and you will see similar options as before.

Screen Shot 2017-09-25 at 18.52.15

There are two ways to make it work:
1- An array that you should add every Language that you have in your game. Each element in this array have two options:

Language: What language the following option is for?
This String: A simple string that will replace the text when your game is on that language.

2- You can set a TXT file and a line to be read by it (number or Title Tag).

2.13.Integrating with Timeline

Timeline is an amazing new feature in Unity for creating cutscenes, and RPGTalk couldn’t be out of it. You can easily integrate these two by simply clicking the Add button in the Timeline window and choosing RPGTalk Cinematic Track.

You need to set an instance of RPGTalk in the scene to command the track. And finally, right click on the track and choose Add RPGTalk Cinematic Clip. There you go!

Screen Shot 2017-09-25 at 19.00.02

The options in the Clip are mostly simple:
Screen Shot 2017-09-25 at 19.21.42
You can set a new Text File to be used by that RPGTalk Instance and choose a line to start reading from. Also, you can choose the text speed. The tag [speed=X] (see more in Tags) won’t work in the cinematic clip.

Usually a RPGTalk Cinematic Clip can only play one line. But if you set to Automatically Pass the Talk, you can set its seconds and more than one line per clip.

The most complex parameter here is the Pause Timeline while waiting for player’s action? If it is not set to true, you can only have one line by clip.
But if it is, you can set the line to start and to break like you would normally do.

timelineThat is possible because RPGTalk will pause the Timeline without loosing what is playing inside it and wait for the talk to finish so it can unpause it. To do so, you need to have the component RPGTalk Timeline (Add Component > RPGTalk > RPGTalk Timeline) attached to the same Object that you have this instance of RPGTalk.
The only option here is who is the Playable Director that is playing that timeline.
But beware!
Take care with the size of the clip when you are waiting for player’s action. If the the text ends before the end of the clip, there is a chance that the player will finish the talk before the timeline even pauses, and then RPGTalk Timeline will not be able to Unpause it automatically (You can still Pause or Unpause any timeline using their Methods).

Note that the parameters changed by the timeline will come back to what they were before if the timeline ends or the clip does.

2.14.Tags

You can use several tags inside of your text to change how RPGTalk should behave around it.

Rich Text:

the most common are the Rich Text tags. RPGTalk can fully make use of rich texts showing them without the user noticing it. RPGTalk support all the Rich Text tags that the UI Text do (the quad and material tags are not supported). See more here.
Example to be placed in your text file:

I can use <b>bold</b>, <i>italic</i>, change my <color=00ffff>color or my <size=30>size

Sprite:

RPGTalk can place images inside the text. They will act just like they were characters. Your text UI must support Rich Text and you must set what sprites to use in the RPGTalk instance, keeping note of its ID. See more in Photos and Sprites.
Example to be placed in your text file:

This line will have a sprite [sprite=0] here and another [sprite=1] here. 

Speed:

You can change the speed of the text while the text is still running so you can make some words appear slowly or faster. You need to specify in the tag what is the new speed, in characters per second, that the text will have. You can also close the tag [/speed] to return to the speed set in RPGTalk.
Example to be placed in your text file:

I will now tell you the biggest [speed=10]plot twist[/speed] in the story. Are you [speed=5]Shocked[/speed] now?

Title

Instead of setting the line as an integer in the RPGTalk, you can set it as a string. If you do this, the instance will look for the tag [title] in your text. It will begin reading the line after a title set in lineToStart, and it will stop reading in the line just before a title set in lineToBreak. See more in Regular Options.
Example to be placed in your text file:

[title=MyTitle]
This line will be read!
This will too!
[title=MyTitleEnd]
This wont =(

Dub:

You can make a sound be played right at the beginning of your talk. You need to set the sounds ID with the RPGTalkDubSounds component (see more in Dubbing).
If you have the name of talker enabled in your RPGTalk, the dub tag must come after the name.
Example to be placed in your text file:

TalkerName: [dub=0] Sound is cool!
TalkerName: [dub=1] Sound is great!
[dub=2]What if sound was one of us?

Line Break:

In your talks, might come a time where you need to break a line, show the rest of the text in a line below. Because RPGTalk reads every line in the txt file as a new talk, it may appears tricky.
But is not, all you have to do is write /n in your text and it will break a line.

This will be in a line. \n This in another! \n But it still a single talk in RPGTalk.

New Talk:

Sometimes in your talks you want to start a new talk right after it, without having to right any more code or create any more Areas. It is specially useful if you need you conversation to change direction depending on player Choices and answers.
The tag have two variables, similar to RPGTalk itself: what line will it start and what line will it break?

Character1: [question=0]Do you remember me?
[choice] Yes, omg!!! [newtalk start=answeredYes_begin break=answeredYes_end]
[choice] No, sorry... [newtalk start=answeredNo_begin break=answeredNo_end]

[title=answeredYes_begin]
Character1: Yeeeeey! I knew you would never forget me!
[title=answeredYes_end]
[title=answeredNo_begin]
Character1: Oh... Ok... I didn't like you anyway...
[title=answeredNo_end]

Save:

If something is saved in your game, you may want to change the conversation. If the player has finished some quest, if the player has killed someone… Or even if the player has answered a question badly other time. Note that for it work right, you need to have the Save Instance Snippet in your RPGTalker Object.
The tag have four variables. Two similar to RPGTalk itself: what line will it start and what line will it break?
The other two is what is the data I should look for, and what modifier will lead to that new conversation.

Save Instance Snippet makes it by itself when we are talking about questions. Something like this:

Character1: [question=IDOFQUESTION]Will you save the world?
[choice] You betcha!
[choice] Nope.

[save start=answeredYes_begin break=answeredYes_end data=IDOFQUESTION mod=0]
[save start=answeredNo_begin break=answeredNo_end data=IDOFQUESTION mod=1]

[title=answeredYes_begin]
Character1: Hey! You are the hero that said that would save the world!
[title=answeredYes_end]
[title=answeredNo_begin]
Character1: Get out of here! No cowards allowed!
[title=answeredNo_end]

Expression:

Sets a flag that a Character can use to change photo or animation based on the expression.

Player:[expression=cry]I'm so sad...

Jitter:

Makes a part of the text jitter. Pretty fun! The first number is the amount of the jitter. The angle is how much the letter will rotate as well. You also need to close the tag to say where should the jitter stop.
Note: It needs TextMeshPro to work.

This is some [jitter=5 angle=1]spoooooky[/jitter] text.

3.Programming Reference

RPGTalk have its code completely open and can be changed to whatever you like.

If you build something cool and wants to share with the community, be sure to talk to us!

3.1.Variables

Public Variables:


	/// Should the talk be initiated when the script starts?


	public bool startOnAwake = true;


	/// An array of objects that will be shown or hidden with the text.Usually, the canvas with the text UI is set here.


	public GameObject[] showWithDialog;


	/// The UI element that holds a Text component


	public Text textUI;



	/// This dialog have the name of the talker? The dialoger?
	
	public bool dialoger;


	/// To show the name of the talker, another UI that holds a Text component is required


	public Text dialogerUI;



	/// Should the element follow someone?


	public bool shouldFollow;



	/// Who to follow? There can be more than one to follow, based on the name of the talker


	public RPGTalkFollow[] follow;



	/// The objects in showWithDialog should be Billboard?


	public bool billboard = true;



	/// If billboard is set to true, should it be based on the main camera?


	public bool mainCamera = true;



	/// If billboard is set to true but not the mainCamera, should it be based on what camera?


	public Camera otherCamera;



	/// The text file that contains all the talks to be parsed.


	public TextAsset txtToParse;	


	/// If the player hits the interaction button, should the text be skipped to the end?


	public bool enableQuickSkip = true;



	/// Some script to look for a feedback when the talk is finished. Leave blank if no feedback is needed


	public MonoBehaviour callbackScript;



	/// Function to be called when the talk finishes. Will only work if some script is set into callbackScript.


	public string callbackFunction;



	/// An animator that some parameters can be set by RPGTalk to help animating while the talk is running


	public Animator animatorWhenTalking;



	/// Name of a boolean property in the animatorWhenTalking that will be set to true when the text is running.

	public string animatorBooleanName;



	/// Name of an int property in animator that represents the talker (based on the photos array).


	public string animatorIntName;



	/// Wich position of the talk are we?


	public int cutscenePosition = 0;



	/// Speed of the text, in characters per second


	public float textSpeed = 50.0f;


	/// wich character of the current line are we?


	public float currentChar = 0.0f;



	/// a list with every element of the Talk. Each element is a line on the text


	public List rpgtalkElements;



	/// A GameObject to blink when expecting player's intercation. It will blink by alternating the GameObject Active property.


	public GameObject blinkWhenReady;



	/// An array that can contain any variable and what is its value to be replaced in the talk


	public RPGTalkVariable[] variables;


	/// Should there be photos of the dialogers?


	public bool shouldUsePhotos;



	/// The photos and who they belong to.


	public RPGTalkPhoto[] photos;



	/// An UI element with the Image property that the photo should be applied to


	public Image UIPhoto;


	/// The dialog and everything in showWithDialog should stay on screen even if the text has ended?


	public bool shouldStayOnScreen;



	/// Audio to be played while the character is talking

	
	
	public AudioClip textAudio;


	/// Audio to be played when player passes the Talk


	public AudioClip passAudio;


	/// Pass the text with mouse Click?


	public bool passWithMouse = true;



	/// Pass the text with some button set on Project Settings > Input


	public string passWithInputButton;



	/// The user can currently pass the talk?


	public bool enablePass = true;



	/// Line to start reading the text. Should not be below 1.
	/// Can be a string that the RPGTalk will look for in the text by the pattern [title=MyString]


	public string lineToStart = "1";


	/// Line to stop reading the text. If it is -1 it will read until the end of the file.
	/// Can be a string that the RPGTalk will look for in the text by the pattern [title=MyString]


	public string lineToBreak = "-1";



	/// Should the RPGTalk try to break long lines into several little ones?


	public bool wordWrap = true;


	/// If wordWrap is set to true, RPGTalk will only accept a line with maxCharInWidth * maxCharInHeight characters.
 If the line in the text passes it, it will be broken into another line.


	public int maxCharInWidth = 50;


	/// If wordWrap is set to true, RPGTalk will only accept a line with maxCharInWidth * maxCharInHeight characters.
 If the line in the text passes it, it will be broken into another line.


	public int maxCharInHeight = 4;



	/// The sprites that can be used in this talk


	public List sprites;



	/// The sprites that are being used in this talk


	public List spritesUsed;



	/// The actual speed that the text will be scrolled. This usually is equal to textSpeed 
but can be changed within the text with the [speed=X] tag


	public float actualTextSpeed;



	/// Is the RPGTalk currently playing the text?


	public bool isPlaying;




	/// The prefab of a Button that will be the choice in case of questions in the text


	public GameObject choicePrefab;


	/// A parent that each choice will be instantiated to in case of questions


	public Transform choicesParent;


        /// A variable that says if the text is animating
        public bool isAnimating;
        /// A variable that says if the talk should pass itself
        public bool autoPass
        /// How many seconds after the text has stopped animating the talk should pass?
        public float secondsAutoPass

3.2.Methods

The There are some useful public methods that can be called when using RPGtalk. These are:

New Talk:
Starts a new talk with every option in the variables. You can this method from several different ways so you can easily change how the new talk will be.
The following code, for instance, starts a new talk in a RPGTalk instance set as “rpgtalk” to start from the line 10 and end in the 12.

rpgtalk.NewTalk("10","12");

The possible parameters are:

string _lineToStart
string _lineToBreak
TextAsset _txtToParse
MonoBehaviour _callbackScript
string _callbackFunction

Play Next:
Plays the next line in the talk. If there are no lines left, it ends the talk.
The only parameter is:

bool forcePlay = false

that checks if the the next line should be played even if the enablePass variable is set to false.

End Talk:
Ends the current talk. The callback functions will still going to be called.
The only parameter is:

bool jumpQuestions = false

if it is false, the talk will jump to any questions found (See choices for more).

3.3.Events

Some events can be called to improve your interaction with RPGTalk.

OnNewTalk
Called when a new Talk Starts

OnPlayNext
Called when the user passes a dialog

OnEndTalk
Called when the user finishes a talk

OnEndAnimating
Called when the text finishes animating

OnMadeChoice
Called when the users answers a question (see more in Choices). This event has two parameters: the ID of the question and the ID of the answer, so you can do whatever you want with that information.
int questionID, int choiceNumber

An exemple of how to use these events:

public Rpgtalk rpgtalk;
void Start(){
rpgtalk.OnMadeChoice += OnMadeChoice;
}



void OnMadeChoice(int questionID, int choiceID){
Debug.Log("Aha! In the question "+questionID+" you choosed the option "+choiceID);
}

3.4.RPGTalkDubSounds

Class used to keep the sounds that will be called by the text. See Dubbing for more.

namespace RPGTALK.Dub

Public variables:

public RPGTalkDubLanguage[] dubsByLanguage;
public AudioMixerGroup audioMixerToUse;

Public methods:

public void PlayDubClip(int clipNum)

Given its ID, plays a dub clip set in the dubsByLanguage array.

public void StopCurrentDub()

Stops whatever clip is playing

3.5.RPGTalkLocalization

Class that keeps and manage the Localization.

namespace RPGTALK.Localization

public class LanguageSettings

has the following static and public variables:

public static SupportedLanguages defaultLanguage = SupportedLanguages.EN_US;

Keeps the default language of the game.

public static SupportedLanguages actualLanguage

What language is the game currently in?

 

public class RPGTalkLocalization

Has a variable to keep the language array and another one static, so you can call RPGTalkLocalization wherever you need to.

public static RPGTalkLocalization singleton;

Methods:

public TextAsset CheckForCorrectLanguage(TextAsset baseTxt)

Given a base text in the default language, returns the textAsset for the actual language

3.6.RPGTalkTimeline

RPGTalkTimeline only needs to be placed in scene when using the timeline feature and waiting for player’s action. See Integrating with Timeline for more.

namespace RPGTALK.Timeline

Variables:

public PlayableDirector timelineDirector

the Playable Director that is playing the timeline.

public bool isPaused

is the timeline currently paused by RPGTalkTimeline?

Methods:

public void Pause()

Pauses the timeline.

public void Resume()

Resumes the timeline

4.Snippets

RPGTalk is highly customisable. And this is awesome. You can do a lot of stuff.
But we like to make your life easier 😉
So we already made a bunch of stuff using RPGTalk’s API. Check it out

4.1.Follow Character

rpgtalk6

This Snippet should be placed in the same object as RPGTalk.

NOTE: This script uses Characters to know who to follow. Make sure you set it right!

 

SetUps:
Canvas: 
Throw your canvas here! The comportment of the snippet changes if your canvas is ScreenSpace.
DialogWindow: This is the object that the snippet will indeed move. Inside a canvas.

Camera Specs
RotateToTarget
: If set, the DialogWindow will have the same rotation as the character.
CameraBillboard: If set, the DialogWindow will always be rotate to the camera.
BasedOnWhatCamera: On what camera the Billboard or the ScreenSpace will be based on

billboard

shouldfollow

These options are awesome for 3D projects.
A Billboard object is always looking for the camera, while a non-Billboard one can fit into its perspective. Check the 3D exemple here with a RPGTalk Billboard and other without.

 

 

Limits
ContainInsideScreen: If set, the Dialog Window will never leave the screen, even if the character moves out of it.
UnitsToMoveWhenOutside: how units should be moved when the character is outside?
MaximumIsInitialPoint: If set, the dialog Window will only try to be contained until its corners hit the initial point. After that, it will move out of the window as it should before.
MaintainZ: ScreenSpace objects may have problems with Z. If this option is checked, the Z won’t be changed.

ezgif.com-video-to-gif (2)

Pointer
Pointer: A pointer can be set to be teleported to the lowest Y of the Dialog Window. If the pointer is a Smart Pointer, the Snippet also set its end point.
PointerInitialOffset: any offset of the pointer?
MantainXDinstanceFromClosestCorner: If set, the X distance that you have set of the closest corner on Dialog Window will be kept. Useful for when you want a left or right pointer.

4.2.Can Pass Warning

rpgtalk7Maybe you want something to happen when the user can pass the talk.
Maybe an arrow that shows up indicating that a player action is needed?

This Snippet have two events, What should happen when the player can pass, What should happen when the player passes.

You can then have your own animation, events, etc.

4.3.Save Instance

This is a very simple Snippet.

It should be placed on the RPGTalk Object.

It only have one option: Save Between Plays?
If not set, everything saved will be erased when the game closes.

It has another checkbox, Erase. This is for debug only, and erase everything saved.

This Snippet is ready to save Choices and Areas. But if you want to save anything else (like quests), it shouldn’t be hard to make your own script based on it.
For programmers: it saves data using PlayerPrefs. Feel free to change the script and use your favorite save method.

4.4.Simple Animation

If you read until here you must already now… RPGTalk is awesome!

But sometimes you don’t need all of those options, tags, events, dialogs, not even read a TXT… You only want to animate a simple Text in the canvas.

Don’t you worry! With this Snippet on any Text or TextMeshPro element, it will make the text animation with the given Text Speed.

You don’t have to be an instance of RPGTalk in your scene to make this Snippet run!

4.5.Skip Cutscene

rpgtalk8This Snippet should be used in the same object that has the RPGTalk Timeline component.

The objective is to skip a cutscene set on Timeline. 

It looks scary, but the options are really simple. The first ones are the same as in RPGTalk, to know what button should be pressed to skip the cutscene.
The new option here is the one that asks if The user have to press the button twice. This is used a lot in big games to display a message like “Press X again to skip the cutscene”.
If this option is set, you will have to say how many seconds before the warning goes out and what events should happen when we hit the first time and don’t hit again.

We also have an event that can be fired when we skip.

We have a few options too.
A simple bool that can block skip.
An option that jumps questions on the cutscene. If not set, your cutscene will be skipped until an option is found.
In the end, you may set a delay when the user skips it. Useful for if you want to make a fade out or something like that.

4.6.Smart Pointer

This snippet needs to be placed inside a Canvas Element.

It is a script that makes a balloon pointer using line Renderer.

The End Point Variable usually is defined by Follow Character Snippet. But you can control it’s Z or an offset.

You can say what is the maximum that this line can stretch. And if it passes the maximum, if it should bend some other way.

Simple, but pretty useful when you don’t have control of the exact character position.

5.BETA - Node Editor

RPGTalk is already pretty nice, but sometimes you want to build your dialog inside unity, not only on a TXT.

We are building something for that.
It is not complete. It has some known bugs and a lot os space to grow. But it is just so awesome that we couldn’t keep it to ourselves!

Just go to the RPGTalk Menu > BETA – Node Editor and a window will popup.

Click New TXT.

Right Click anywhere on the new window, go to RPGTalk > Dialog Node.
A dialog node will appear where you can set the Title, the Character that is talking (automatically gathered from every Character on the project), and the dialog line.

Feel free to create another and connect the two! Just clic and drag the blue arrows. This way, they will be under the same title, and be part of the same dialog!

node0

You can also create a Choice Node. When you connect it to a Dialog Node, an option appears in it showing the ID of the question.
You can connect how many choice nodes you want to a Dialog Node that will be the question.
After that, you can connect the choice nodes to a new Dialog Node that will be the follow up conversation if the player has chose this answer.

node1

There is another node, Save Node. You can use it like it were a Save Tag on your TXT. The conversation changes if something was saved.

node2

Don’t forget to Save your TXT before closing the window.
You can then use the generated TXT in your RPGTalk components! Nice!
You can also load TXT to edit then as nodes.