How to add an Action to a DialogueSystemTrigger componenet threw scripting

Announcements, support questions, and discussion for the Dialogue System.
ChaChaCHAT
Posts: 24
Joined: Mon Aug 01, 2022 7:58 am

How to add an Action to a DialogueSystemTrigger componenet threw scripting

Post by ChaChaCHAT »

I think the question is self explanatory, I have a dialogue system trigger component. I want to set the conversation at run time as well as the way it is trigger etc.

So far, i havbe set the conversation with the conversation property and same for the trigger. But how do I add the action StartConversation in code as well as posibly modifying some of the property of this action?
User avatar
Tony Li
Posts: 21958
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting

Post by Tony Li »

Hi,

They're all just variables in the DialogueSystemTrigger script. You can set them in your own code. Example:

Code: Select all

var dsTrigger = GetComponent<DialogueSystemTrigger>();
dsTrigger.trigger = DialogueSystemTriggerEvent.OnUse;
dsTrigger.conversation = "Hello World";
dsTrigger.conversationConversant = this.transform;
dsTrigger.conversationActor = player.transform;
ChaChaCHAT
Posts: 24
Joined: Mon Aug 01, 2022 7:58 am

Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting

Post by ChaChaCHAT »

yes thanks for the reply, however, i got that already, my problem is that I don't understand how to tell the trigger to start the conversation on use! this is the problem. I dont know how to add an action threw the script...
User avatar
Tony Li
Posts: 21958
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting

Post by Tony Li »

I don't understand. Do you mean you want to tell the Dialogue System Trigger to activate (e.g., perform its configured actions such as starting a conversation)? If so, then if the trigger value is set to OnUse, you can just call the OnUse() method:

Code: Select all

var dsTrigger = GetComponent<DialogueSystemTrigger>();
dsTrigger.OnUse();
You can also start a conversation without using a Dialogue System Trigger by calling DialogueManager.StartConversation():

Code: Select all

DialogueManager.StartConversation("Hello World");
ChaChaCHAT
Posts: 24
Joined: Mon Aug 01, 2022 7:58 am

Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting

Post by ChaChaCHAT »

Yes but i want to configure said actions via script. for example, i want to say via script onUse you will start conversation "xyz" but instead of doing so in the editor it has to be done in code.
User avatar
Tony Li
Posts: 21958
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting

Post by Tony Li »

I'm sorry; I still don't understand the issue. What specifically are you asking how to do?
ChaChaCHAT
Posts: 24
Joined: Mon Aug 01, 2022 7:58 am

Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting

Post by ChaChaCHAT »

On the dialogue system trigger component in the inspector, under the Action category, you have a button called Add Action. When you click on it, you can select some action you want to trigger on use such as "Start Conversation". I don't want to manually set this action in the inspector but threw code. Is it more clear?
User avatar
Tony Li
Posts: 21958
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting

Post by Tony Li »

Through code, you don't need to do anything related to "Add Action". As long as you set the conversation variable, it will play the conversation.
ChaChaCHAT
Posts: 24
Joined: Mon Aug 01, 2022 7:58 am

Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting

Post by ChaChaCHAT »

OK, well I am doing exactly what you told me but it doesn't work. Note that I'm in VR and I've check the VR scene example. I literally copied the canva, from the example. i put the move dialog script on the npc, I added a listener to the button to do the onUse method on the button click. And it doesnt't do anything
User avatar
Tony Li
Posts: 21958
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting

Post by Tony Li »

Does your scene have a Dialogue Manager GameObject?

Is the Dialogue System Trigger's "trigger" variable set to OnUse?

Are any Conditions blocking the actions?

Are there any errors or warnings in the Console window?
Post Reply