Priority conversation

Announcements, support questions, and discussion for the Dialogue System.
claudius_I
Posts: 33
Joined: Tue Aug 08, 2017 4:06 pm

Priority conversation

Post by claudius_I »

Hi, sorry for my bad english :?

i have a problem:

in a NPC (Gameobject) have 2 conversation trigger (2 different dialogues).

i want to know how put priority a one of this dialogues.

thanks
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Priority conversation

Post by Tony Li »

Hi,

Each Conversation Trigger has a Condition section. You can use a Dialogue System variable.

For example, let's say you have two conversations:
  • Lesson 1
  • Lesson 2
You can define a Boolean variable named "FinishedLesson1" that starts False. At the end of the Lesson 1 conversation, set the variable True. (In the Script field: Variable["FinishedLesson1"] = true)

Then set the Conditions on the Conversation Triggers:
  • Lesson 1: Condition > Lua Conditions: Variable["FinishedLesson1"] == false
  • Lesson 2: Condition > Lua Conditions: Variable["FinishedLesson1"] == true
claudius_I
Posts: 33
Joined: Tue Aug 08, 2017 4:06 pm

Re: Priority conversation

Post by claudius_I »

Tony Li wrote:Hi,

Each Conversation Trigger has a Condition section. You can use a Dialogue System variable.

For example, let's say you have two conversations:
  • Lesson 1
  • Lesson 2
You can define a Boolean variable named "FinishedLesson1" that starts False. At the end of the Lesson 1 conversation, set the variable True. (In the Script field: Variable["FinishedLesson1"] = true)

Then set the Conditions on the Conversation Triggers:
  • Lesson 1: Condition > Lua Conditions: Variable["FinishedLesson1"] == false
  • Lesson 2: Condition > Lua Conditions: Variable["FinishedLesson1"] == true
ok thanks, but if i need a random conversation?
how i do this?
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Priority conversation

Post by Tony Li »

You could use a random variable. Let's say you create a Number variable named "X".

The first step is to assign a random value when the scene starts. Add a Lua Trigger to your scene, set the Trigger to OnStart, and set Lua Code to:

Code: Select all

Variable["X"] = math.random(3)
Then set your Conversation Triggers' Conditions to:
  • Lesson 1: Condition > Lua Conditions: Variable["X"] == 1
  • Lesson 2: Condition > Lua Conditions: Variable["X"] == 2
  • Lesson 3: Condition > Lua Conditions: Variable["X"] == 3
Finally, you'll want to re-randomize "X" at the end of the conversation. Add a Lua On Dialogue Event component to the NPC. Set the Trigger to OnConversation. Add an element to On End, and use the same Lua as before:

Code: Select all

Variable["X"] = math.random(3)
Another approach is to skip all of these components. Use a single Conversation Trigger. In the conversation, set a random variable and branch to different sub-conversations as described in this post.
claudius_I
Posts: 33
Joined: Tue Aug 08, 2017 4:06 pm

Re: Priority conversation

Post by claudius_I »

thanks :D

an the last question? (i hope so :roll: )

in set enable on dialogue event. the only one script disable is selector. how i can fix that?
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Priority conversation

Post by Tony Li »

claudius_I wrote:in set enable on dialogue event. the only one script disable is selector. how i can fix that?
Do you want to assign more scripts? If so, increase the Size fields. This will make the lists bigger so you can assign more scripts.

If that's not the problem, please reply with more details or a screenshot explaining what you want to do.
claudius_I
Posts: 33
Joined: Tue Aug 08, 2017 4:06 pm

Re: Priority conversation

Post by claudius_I »

Tony Li wrote:
claudius_I wrote:in set enable on dialogue event. the only one script disable is selector. how i can fix that?
Do you want to assign more scripts? If so, increase the Size fields. This will make the lists bigger so you can assign more scripts.

If that's not the problem, please reply with more details or a screenshot explaining what you want to do.
Image

I only can select (gameobject) in target and always is the same script (protagonista).

other problem that i have is when the conversation start. The name of the character is the name of the (Gameobject) and not the that writed in dialogue database.
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Priority conversation

Post by Tony Li »

claudius_I wrote:I only can select (gameobject) in target and always is the same script (protagonista).
You can drag a specific component into the target slot. Click and hold on the component title, and drag it into the target slot.

If the component is on a different GameObject, you'll need to use two Inspector tabs: To open another Inspector tab, right-click on another tab such as Game and select Add > Inspector. On one Inspector, select the GameObject with the Set Enabled On Dialogue Event, and click the padlock in the upper right to lock it. Then select the other GameObject, and drag the component title from one Inspector to the other.
claudius_I wrote:other problem that i have is when the conversation start. The name of the character is the name of the (Gameobject) and not the that writed in dialogue database.
This is by design. (See here for details.) Add an Override Actor Name component, and set the name that you want to appear in the UI.
claudius_I
Posts: 33
Joined: Tue Aug 08, 2017 4:06 pm

Re: Priority conversation

Post by claudius_I »

Tony Li wrote:
claudius_I wrote:I only can select (gameobject) in target and always is the same script (protagonista).
You can drag a specific component into the target slot. Click and hold on the component title, and drag it into the target slot.
this was very stupid :lol: i an a idiot :(

i did't knew this form :shock:

thanks...
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Priority conversation

Post by Tony Li »

No worries! Unity is full of little tricks like this.
Post Reply