Page 1 of 4
How to add an Action to a DialogueSystemTrigger componenet threw scripting
Posted: Tue Jan 03, 2023 11:42 am
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?
Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting
Posted: Tue Jan 03, 2023 1:54 pm
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;
Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting
Posted: Tue Jan 03, 2023 2:01 pm
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...
Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting
Posted: Tue Jan 03, 2023 2:15 pm
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");
Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting
Posted: Tue Jan 03, 2023 2:43 pm
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.
Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting
Posted: Tue Jan 03, 2023 3:23 pm
by Tony Li
I'm sorry; I still don't understand the issue. What specifically are you asking how to do?
Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting
Posted: Tue Jan 03, 2023 9:59 pm
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?
Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting
Posted: Wed Jan 04, 2023 8:26 am
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.
Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting
Posted: Wed Jan 04, 2023 2:52 pm
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
Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting
Posted: Wed Jan 04, 2023 4:03 pm
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?