I want to use a dialogue node several times. But have the same node say something different every time (mostly). For instance, you say hello to the shopkeeper. The first time he answers. “Welcome” the second time, “welcome back.” The third time “have I seen you before?”
And I want to do this a lot.
Following the barks and quest video tutorial, I can get this behavior. But this makes the dialogue tree super complex, extremely fast.
So, my question is, has someone found a better way to do this? I was thinking having each dialogue node look at an array or lists of responses and having a function to go one by one each time, or maybe choose randomly.
Thanks.
Different redaction for the same dialgue node.
-
- Posts: 40
- Joined: Mon May 24, 2021 7:22 pm
Re: Different redaction for the same dialgue node.
Hi,
For a non-scripting option, you can link the <START> node to several dialogue nodes, each one with a different line of text ("Welcome", "Welcome back", "Hi there", etc.). You can put Conditions on them so that, for example, "Welcome back" only appears if the player has spoken to the NPC before.
In addition, you can use the RandomElement() Lua function if you want to include random text:
For a non-scripting option, you can link the <START> node to several dialogue nodes, each one with a different line of text ("Welcome", "Welcome back", "Hi there", etc.). You can put Conditions on them so that, for example, "Welcome back" only appears if the player has spoken to the NPC before.
In addition, you can use the RandomElement() Lua function if you want to include random text:
- Dialogue Text: "[lua(RandomElement( "Welcome|Welcome back|Hi there" ))]"
- Dialogue Text: "[lua(RandomElement( "Welcome|Welcome back|Hi there" ))], [lua(RandomElement("friend|buddy"))]"
Code: Select all
public string[] greetings = new string[] { "Welcome", "Welcome back", "Hi there" };
void OnConversationLine(Subtitle subtitle) // Make sure script is on Dialogue Manager or conversation participant.
{
if (subtitle.formattedText.text.Contains("{greeting}"))
{
string randomGreeting = greetings[Random.Range(0, greetings.Length)];
subtitle.formattedText.text = subtitle.formattedText.text.Replace("{greeting}", randomGreeting);
}
}
-
- Posts: 40
- Joined: Mon May 24, 2021 7:22 pm
Re: Different redaction for the same dialgue node.
Thanks. Gonna try it.