Page 1 of 2

Change subtitle panel runtime

Posted: Sun Nov 26, 2023 1:08 pm
by MasterDataBase
Hi everyone
In my project I'm facing an unusual use case, and maybe I'm using the wrong approach.
In my project, turn based game, I use the dialogue for feedback after every action, so I have one database for all the dialogue line, inside, for every character, then a conversation, and each node will be fired when the related action is triggered on the game.
Now I have a section of the game where 2 character can interact, so at the start of these phases I change the Dialogue UI Canvas with another one, in this canvas I have one panel NPC and another one PC as for the standard.
Now my problem is, how I can set via script the relation between the character in these phases and the subtitle?
Because in these moments, I have two characters, one who attacks, and the other who has to defend, and I would like to keep the attacker always on the left and the defender on the right, regardless of the characters. I have tried changing the subtitle panel in the Dialogue Actor component, but I am not getting results

What I'm missing?

Re: Change subtitle panel runtime

Posted: Sun Nov 26, 2023 3:03 pm
by Tony Li
While a conversation is active, you have two options:

To use a specific subtitle panel for a single dialogue entry, include a [panel=#] markup tag in your dialogue text.

To switch an actor to using a specific subtitle panel going forward, use the SetPanel() sequencer command.

Re: Change subtitle panel runtime

Posted: Sun Dec 03, 2023 9:06 am
by MasterDataBase
Hi Tony

Thanks a lot, your hint it was really helpful!
But now I have another question, how I trigger two different nodes from 2 different databases in the same times? because at this moment I'm using the current block code, but just the first line was triggered

Code: Select all

        dsController.UseDialogueUI(dialogueFight);

        var currentPlayer = PlayerController.Instance.CurrentPlayer;

        //DialogueActor 

        DialogueSystemTrigger dsTrigger;

	// Here i get the current player with his own Diualogue System Trigger component
        dsTrigger = e.playerRobbing.GetComponent<DialogueSystemTrigger>();

        DialogueLua.SetVariable("StartFight", true);

        dsTrigger.OnUse(dsTrigger.transform);

        dsTrigger = e.playerToRob.GetComponent<DialogueSystemTrigger>();

	//This line will not be triggered
        DialogueLua.SetVariable("RobberyLand", true);

        dsTrigger.OnUse(dsTrigger.transform);

        DialogueLua.SetVariable("StartFight", false);
        DialogueLua.SetVariable("RobberyLand", false);
Maybe there is another way to fire 2 different node in the same way?

Re: Change subtitle panel runtime

Posted: Sun Dec 03, 2023 9:12 am
by Tony Li
Hi,

At runtime, all loaded databases are merged into a single database in memory called DialogueManager.masterDatabase. (Like your username! ;))So technically you are starting two conversations from the same masterDatabase.

To allow the Dialogue Manager to run two conversations at the same time:

1. You must tick the Dialogue Manager's Other Settings > Allow Simultaneous Conversations.

2. Each conversation must use a different dialogue UI. You can use Override Dialogue UI components to do this.

Re: Change subtitle panel runtime

Posted: Sun Dec 03, 2023 12:11 pm
by MasterDataBase
Sorry, but I'm here again because I got anyway some trouble.

I set up everything correctly, but I don't get the code in the right way

this is the code now

Code: Select all

        e.playerRobbing.GetComponent<OverrideDialogueUI>().ui = dialogueFight;
        e.playerToRob.GetComponent<OverrideDialogueUI>().ui = dialogueFight;

        dsTriggerRobber = e.playerRobbing.GetComponent<DialogueSystemTrigger>();
        dsTriggerRobbed = e.playerToRob.GetComponent<DialogueSystemTrigger>();

        DialogueLua.SetVariable("StartFight", true);
        DialogueLua.SetVariable("RobberyLand", true);

        dsTriggerRobber.OnUse(dsTriggerRobber.transform);
        dsTriggerRobbed.OnUse(dsTriggerRobbed.transform);

        DialogueLua.SetVariable("StartFight", false);
        DialogueLua.SetVariable("RobberyLand", false);
But anyway it trigger just the first line, and not the second one
There is some change required in the code?

Re: Change subtitle panel runtime

Posted: Sun Dec 03, 2023 4:26 pm
by Tony Li
Hi,

Code: Select all

       e.playerRobbing.GetComponent<OverrideDialogueUI>().ui = dialogueFight;
        e.playerToRob.GetComponent<OverrideDialogueUI>().ui = dialogueFight;
Different conversations must use different dialogue UIs.

However, I don't think this is what you want to do.

What do you want to happen? Can you provide a diagram or mock-up picture?

Re: Change subtitle panel runtime

Posted: Tue Dec 05, 2023 1:18 pm
by MasterDataBase
Thanks for your answer Tony, here some more information
The idea is to fullfil this 2 panel, the one on the left with the information of the "attacker" and on the right with the "defender" line
Immagine 2023-12-05 185739.png
Immagine 2023-12-05 185739.png (593.92 KiB) Viewed 16053 times
and here I have on example of 2 different node that i would trigger in the same moment
Attacker
Immagine 2023-12-05 190350.png
Immagine 2023-12-05 190350.png (28.43 KiB) Viewed 16053 times
This one below is the defender
Immagine 2023-12-05 190921.png
Immagine 2023-12-05 190921.png (27.92 KiB) Viewed 16053 times
Here, as I attach before, but just to keep everything toghether, the code I'm using

Code: Select all

    private void Instance_OnStartRob(object sender, RobbingArgs e)
    {


        dsController.UseDialogueUI(dialogueFight);

        var currentPlayer = PlayerController.Instance.CurrentPlayer;

        //DialogueActor 

        DialogueSystemTrigger dsTriggerRobber, dsTriggerRobbed;

        e.playerRobbing.GetComponent<OverrideDialogueUI>().ui = dialogueFight;
        e.playerToRob.GetComponent<OverrideDialogueUI>().ui = dialogueFight;

        dsTriggerRobber = e.playerRobbing.GetComponent<DialogueSystemTrigger>();
        dsTriggerRobbed = e.playerToRob.GetComponent<DialogueSystemTrigger>();

        DialogueLua.SetVariable("StartFight", true);
        DialogueLua.SetVariable("RobberyLand", true);

        dsTriggerRobber.OnUse(dsTriggerRobber.transform);
        dsTriggerRobbed.OnUse(dsTriggerRobbed.transform);

        DialogueLua.SetVariable("StartFight", false);
        DialogueLua.SetVariable("RobberyLand", false);

        //StartCoroutine(Delay(e.playerToRob));
    }
Now my idea is to take from 2 differen database (but as you said everything is merged in the same database)
in the same time (or at the least with one second of different) both of the line, and have for few seconds both of the line on the screen.

If need, this is the Trigger Component
Immagine 2023-12-05 191650.png
Immagine 2023-12-05 191650.png (41.54 KiB) Viewed 16053 times
The UI in the override component will be setted only when necessary as you can see in the code.

Re: Change subtitle panel runtime

Posted: Tue Dec 05, 2023 3:22 pm
by Tony Li
I don't think these need to be separate conversations. In fact, two barks may be better. Here's an example that uses two barks:

DS_TwoBarksExample_2023-12-05.unitypackage

Notice that the example doesn't need OverrideDialogueUI components or, in this case, any code at all.

Re: Change subtitle panel runtime

Posted: Sat Dec 09, 2023 9:44 am
by MasterDataBase
Tony you are incredible!
thanks a lot for your work!
now it seems also work pretty fine, but, there is a "small" problem, to let it work I had to delete from the Dialogue System Trigger, the conversation action, (that was setted after the bark).
But i setted a lot of line before to be fired as conversation (as also as you said, the bark should work better, but at time I was too naive).
So there is a way to keep everything togheter? or is better to move everything to the Bark?

Re: Change subtitle panel runtime

Posted: Sat Dec 09, 2023 10:06 am
by Tony Li
For consistency, I recommend using barks. However, if you really want to use your existing conversations, you can do that. Try setting the NPCs' Dialogue Actor components > Dialogue UI Settings > Subtitle Panel to Use Bark UI. To make the barks appear at the same time, set the first dialogue entry's Sequence to:

Code: Select all

Continue()@0