Change subtitle panel runtime
-
- Posts: 8
- Joined: Tue Apr 25, 2023 8:22 am
Change subtitle panel runtime
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?
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
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.
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.
-
- Posts: 8
- Joined: Tue Apr 25, 2023 8:22 am
Re: Change subtitle panel runtime
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
Maybe there is another way to fire 2 different node in the same way?
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);
Re: Change subtitle panel runtime
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.
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.
-
- Posts: 8
- Joined: Tue Apr 25, 2023 8:22 am
Re: Change subtitle panel runtime
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
But anyway it trigger just the first line, and not the second one
There is some change required in the code?
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);
There is some change required in the code?
Re: Change subtitle panel runtime
Hi,
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?
Code: Select all
e.playerRobbing.GetComponent<OverrideDialogueUI>().ui = dialogueFight;
e.playerToRob.GetComponent<OverrideDialogueUI>().ui = dialogueFight;
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?
-
- Posts: 8
- Joined: Tue Apr 25, 2023 8:22 am
Re: Change subtitle panel runtime
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 and here I have on example of 2 different node that i would trigger in the same moment
Attacker This one below is the defender Here, as I attach before, but just to keep everything toghether, the code I'm using
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 The UI in the override component will be setted only when necessary as you can see in the code.
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 and here I have on example of 2 different node that i would trigger in the same moment
Attacker This one below is the defender 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));
}
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 The UI in the override component will be setted only when necessary as you can see in the code.
Re: Change subtitle panel runtime
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.
DS_TwoBarksExample_2023-12-05.unitypackage
Notice that the example doesn't need OverrideDialogueUI components or, in this case, any code at all.
-
- Posts: 8
- Joined: Tue Apr 25, 2023 8:22 am
Re: Change subtitle panel runtime
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?
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
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