Page 1 of 1

Selector And Usable

Posted: Thu Sep 08, 2022 10:39 pm
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.

Re: Selector And Usable

Posted: Fri Sep 09, 2022 9:07 am
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 240 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 240 times

Re: Selector And Usable

Posted: Fri Sep 09, 2022 6:24 pm
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?

Re: Selector And Usable

Posted: Fri Sep 09, 2022 6:24 pm
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?

Re: Selector And Usable

Posted: Fri Sep 09, 2022 9:16 pm
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());
}