How to add an Action to a DialogueSystemTrigger componenet threw scripting
-
- Posts: 24
- Joined: Mon Aug 01, 2022 7:58 am
How to add an Action to a DialogueSystemTrigger componenet threw scripting
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?
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
Hi,
They're all just variables in the DialogueSystemTrigger script. You can set them in your own code. Example:
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;
-
- Posts: 24
- Joined: Mon Aug 01, 2022 7:58 am
Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting
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
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:
You can also start a conversation without using a Dialogue System Trigger by calling DialogueManager.StartConversation():
Code: Select all
var dsTrigger = GetComponent<DialogueSystemTrigger>();
dsTrigger.OnUse();
Code: Select all
DialogueManager.StartConversation("Hello World");
-
- Posts: 24
- Joined: Mon Aug 01, 2022 7:58 am
Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting
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
I'm sorry; I still don't understand the issue. What specifically are you asking how to do?
-
- Posts: 24
- Joined: Mon Aug 01, 2022 7:58 am
Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting
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
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.
-
- Posts: 24
- Joined: Mon Aug 01, 2022 7:58 am
Re: How to add an Action to a DialogueSystemTrigger componenet threw scripting
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
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?
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?