Page 1 of 1
Trigger dialogue
Posted: Tue Dec 03, 2024 5:12 pm
by jrose1184
Hi,
So I have a battle system and I have a npc that I want to talk to me at random parts of the battle. I want to trigger a dialogue and point the camera at him when he says somthing. So if I create a tree of different dialogues. How do I trigger this event though script and what components would the npc needs. Thanks
Re: Trigger dialogue
Posted: Tue Dec 03, 2024 11:35 pm
by Tony Li
Hi,
To start a conversation from C#, use
DialogueManager.StartConversation(). Example:
Code: Select all
DialogueManager.StartConversation("Combat Remarks", player.transform, npc.transform);
In the conversation's first dialogue entry node, you can use a Sequence such as this one to point the camera at the NPC, assuming the node is assigned to the NPC:
To randomize it, you should set up the conversation like this:

- combatRemarks.png (26.94 KiB) Viewed 4374 times
Alternatively, you can use
barks.
Re: Trigger dialogue
Posted: Wed Dec 04, 2024 4:52 pm
by jrose1184
Hi Thanks.
I think im doing somthing wrong.
So i added a Dialogue Actor to my Npc and assigned it's Actor.
Then in my converstations i copied your tree but on the first node i add a condition
Variable["LemonBattleCam"] == true - this is my empty gameobject that will be my camera.
then underneath that i assigned another 3 nodes and set 3 conditions to each one i.e
Variable["Intro"] == true
Variable["Block"] == true
Variable["WrongAttack"] == true
Then in my code i add
DialogueLua.SetVariable("LemonBattleCam", true);
but it does not work.
If i remove that condition on the parent node and use
DialogueManager.StartConversation("Battle Demo", player.transform, lemon.transform);
that does opens the converstation window but its blank. as im not using that bool.
It also does not point the camera, i alrready have a few cameras set up in my scene using cinemachine and in script im changing all the cameras prority to 10 and the active one to 100, So i need to override the 100 with this.
again im trying to set a bool to true to trigger that converstation i.e
DialogueLua.SetVariable("Intro", true);
Re: Trigger dialogue
Posted: Wed Dec 04, 2024 5:10 pm
by jrose1184
I managed to fix the camera with Cinemachine Priority On Dialogue Event
Just cant get the bools to work in c#
Re: Trigger dialogue
Posted: Wed Dec 04, 2024 8:12 pm
by Tony Li
Hi,
This example may be helpful:
How To: Run a Conversation Only Once. It's not exactly what you're doing, but it explains how to check a DS variable in a conversation, and it has screenshots.
See also the
Logging & Debugging tutorial video. It explains how to turn on debug logging to see what the Dialogue System is doing under the hood -- when it's setting and checking variables, when it's starting conversations, etc.
Re: Trigger dialogue
Posted: Fri Dec 06, 2024 5:41 pm
by jrose1184
Thanks i went with this and it worked
DialogueLua.SetVariable("Intro", false);
bool isTrue = DialogueLua.GetVariable("Intro").AsBool;
Debug.Log($"Intro Variable Value Before Starting: {isTrue}");
DialogueManager.StartConversation("Battle Demo");