Selector And Usable

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
SBSun
Posts: 46
Joined: Thu Sep 08, 2022 6:39 pm

Selector And Usable

Post by SBSun »

I recently purchased an asset and had a question, so I wrote a post.

I wonder if it is right to add a Selector and Usable to each NPC if it is possible to talk between NPCs.
User avatar
Tony Li
Posts: 21970
Joined: Thu Jul 18, 2013 1:27 pm

Re: Selector And Usable

Post by Tony Li »

Hi,

Only add one Selector -- typically on the player.

Add a Usable to every NPC that the player can select with the Selector.

Yes, it's possible to talk between NPCs. Assign the NPCs as the conversation's Actor and Conversant:

npcConversation1.png
npcConversation1.png (24.27 KiB) Viewed 239 times

(Use Menu > Conversation Properties to access the conversation's Actor and Conversant dropdowns.)

In the Dialogue System Triger, assign the NPC1 and NPC2 GameObjects if present in the scene. In the example below, the Dialogue System Trigger is configured to play the conversation when the player enters the trigger collider:

npcConversation2.png
npcConversation2.png (36.63 KiB) Viewed 239 times
SBSun
Posts: 46
Joined: Thu Sep 08, 2022 6:39 pm

Re: Selector And Usable

Post by SBSun »

Thank you for your kind reply.

I have another question.

1. Is it possible to dynamically set the NPC object that initiates a conversation when talking between NPCs as a script in-game?

2. I want to give a condition on which text to output as a script during conversation. Is there any document I can refer to?
SBSun
Posts: 46
Joined: Thu Sep 08, 2022 6:39 pm

Re: Selector And Usable

Post by SBSun »

Thank you for your kind reply.

I have another question.

1. Is it possible to dynamically set the NPC object that initiates a conversation when talking between NPCs as a script in-game?

2. I want to give a condition on which text to output as a script during conversation. Is there any document I can refer to?
User avatar
Tony Li
Posts: 21970
Joined: Thu Jul 18, 2013 1:27 pm

Re: Selector And Usable

Post by Tony Li »

Hi,
SBSun wrote: Fri Sep 09, 2022 6:24 pm1. Is it possible to dynamically set the NPC object that initiates a conversation when talking between NPCs as a script in-game?
Yes, you can specify the conversation actor and conversant GameObjects in DialogueManager.StartConversation(). I recommend adding Dialogue Actor components to these GameObjects and setting their Actor dropdowns. Helpful info: Character GameObject Assignments (recommended to read).
SBSun wrote: Fri Sep 09, 2022 6:24 pm2. I want to give a condition on which text to output as a script during conversation. Is there any document I can refer to?
If I understand correctly, here are two ways to use a script to show dialogue text:

1. Register your C# script method with Lua. (See: Registering Functions) Then use the [lua(code)] markup tag. Example:
  • Dialogue Text: "Good morning, listeners! The weather is going to be [lua(GetWeatherReport())] today."
2. Or use an OnConversationLine method. Example:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    // Replace the string "{weather}" with the value of the GetWeatherReport() method:
    subtitle.formattedText.text = subtitle.formattedText.text.Replace("{weather}", GetWeatherReport());
}
Post Reply