# Manual invoke a narrative trigger in Unity using script

**URL:** <https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564>\
**Category:** Unity SDK\
**Tags:** question, vr, unity\
**Created:** [August 31, 2024, 12:26am UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564 "2024-08-31T00:26:52Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)\
**Post date:** [September 1, 2024, 12:33am UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564/21 "2024-09-01T00:33:26Z")

</div>

**Reply by k3kalinix | 2024-09-01 00:33:26**

Please follow these steps.

> **[Discord - Group Chat That’s All Fun & Games](https://discord.com/channels/890819304386338856/1277655964962783245/1278033099149545595)**
>
> Discord is great for playing games and chilling with friends, or even building a worldwide community. Customize your own space to talk, play, and hang out.

---

<div class="post-metadata">

**Author:** ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)\
**Post date:** [September 1, 2024, 10:25pm UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564/22 "2024-09-01T22:25:51Z")

</div>

**Reply by petroslouca | 2024-09-01 22:25:51**

I attached the “NarrativeDesignTrigger” on each avatar and created a new game object. Then attached a script with the following function, thus when calling a public function passing to it the required parameters, i.e. I select the AVATAR index number from an array, set it as active and then select the required trigger index again from the hard-coded narrative designer trigger index, I have achieved a simple and efficient opearion as desired:

public void AvatarNarrativeTrigger(ConvaiNPC NPCs, int TriggerIndex)  
{  
if (NPCs.TryGetComponent(out NarrativeDesignTrigger narrativeDesignTrigger))  
{ConvaiNPCManager.Instance.SetActiveConvaiNPC(NPCs);  
NPCs.isCharacterActive= true;  
narrativeDesignTrigger.selectedTriggerIndex = TriggerIndex;  
narrativeDesignTrigger.InvokeSelectedTrigger();  
}  
}

---

<div class="post-metadata">

**Author:** ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)\
**Post date:** [September 1, 2024, 10:27pm UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564/23 "2024-09-01T22:27:48Z")

</div>

**Reply by k3kalinix | 2024-09-01 22:27:48**

Yes, it works.

---

<div class="post-metadata">

**Author:** ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)\
**Post date:** [September 1, 2024, 10:29pm UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564/24 "2024-09-01T22:29:18Z")

</div>

**Reply by petroslouca | 2024-09-01 22:29:18**

Public function sample:

public void Medieval\_Outlander\_PumpkinTrigger()  
{  
AvatarNarrativeTrigger(NPCs[0], 1);  
}

---

<div class="post-metadata">

**Author:** ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)\
**Post date:** [September 1, 2024, 10:33pm UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564/25 "2024-09-01T22:33:52Z")

</div>

**Reply by petroslouca | 2024-09-01 22:33:52**

In a strange way, the NPC talks but the text does not always appear on the chatbox! Is there something that should be enabled/triggered to ensure that the NPC’s text appears in the chatbox?

---

<div class="post-metadata">

**Author:** ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)\
**Post date:** [September 1, 2024, 10:34pm UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564/26 "2024-09-01T22:34:35Z")

</div>

**Reply by petroslouca | 2024-09-01 22:34:35**

This happens only when performing a narrative trigger. Using the Mic there is no issue.

---

<div class="post-metadata">

**Author:** ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)\
**Post date:** [September 1, 2024, 10:35pm UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564/27 "2024-09-01T22:35:22Z")

</div>

**Reply by k3kalinix | 2024-09-01 22:35:22**

Probably a bug fixed in the new version.

---

<div class="post-metadata">

**Author:** ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)\
**Post date:** [September 1, 2024, 10:36pm UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564/28 "2024-09-01T22:36:40Z")

</div>

**Reply by k3kalinix | 2024-09-01 22:36:40**

> **[Discord - Group Chat That’s All Fun & Games](https://discord.com/channels/890819304386338856/1276545087160979456/1277871888743530537)**
>
> Discord is great for playing games and chilling with friends, or even building a worldwide community. Customize your own space to talk, play, and hang out.

---

<div class="post-metadata">

**Author:** ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)\
**Post date:** [September 1, 2024, 10:36pm UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564/29 "2024-09-01T22:36:41Z")

</div>

**Reply by petroslouca | 2024-09-01 22:36:41**

I undestand, what is the way to upgrade without the risk of losing any of my game functionalities?

---

<div class="post-metadata">

**Author:** ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)\
**Post date:** [September 1, 2024, 10:36pm UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564/30 "2024-09-01T22:36:55Z")

</div>

**Reply by k3kalinix | 2024-09-01 22:36:55**

Try this

---

<div class="post-metadata">

**Author:** ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)\
**Post date:** [September 1, 2024, 10:42pm UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564/31 "2024-09-01T22:42:04Z")

</div>

**Reply by petroslouca | 2024-09-01 22:42:04**

Yes, it worked! Thank you very much for your support and immediate response!

---

<div class="post-metadata">

**Author:** ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)\
**Post date:** [September 2, 2024, 9:55am UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564/32 "2024-09-02T09:55:41Z")

</div>

**Replying to petroslouca’s Message**

> **Reply by petroslouca | 2024-09-01 22:42:04**  
> Yes, it worked! Thank you very much for your support and immediate response!

**Reply by k3kalinix | 2024-09-02 09:55:41**

You are Welcome! 😊 \<@606256062613684224\>

If you have any other questions, please do not hesitate to ask.

We would be very grateful if you could leave a comment on our store pages with your company name or the name of your project. We value your feedback and comments as they help us improve our services and products.  
Asset Store: [NPC AI Engine - Dialog, actions, voice and lipsync - Convai | Behavior AI | Unity Asset Store](https://assetstore.unity.com/packages/tools/behavior-ai/npc-ai-dialog-actions-and-general-intelligence-by-convai-235621#reviews)

**Embedded Content:**  
**NPC AI Engine - Dialog, actions, voice and lipsync - Convai | Behav…**  
Get the NPC AI Engine - Dialog, actions, voice and lipsync - Convai package from Convai and speed up your game development process. Find this & other Behavior AI options on the Unity Asset Store.  
Link: [NPC AI Engine - Dialog, actions, voice and lipsync - Convai | Behavior AI | Unity Asset Store](https://assetstore.unity.com/packages/tools/behavior-ai/npc-ai-dialog-actions-and-general-intelligence-by-convai-235621)

 ![Thumbnail](https://canada1.discourse-cdn.com/flex004/uploads/convai/original/1X/007a1958390a9f1f94936341fcca5647e9775c13.jpeg)

---

<div class="post-metadata">

**Author:** ![K3](https://yyz2.discourse-cdn.com/flex004/user_avatar/forum.convai.com/k3/32/2611_2.png) [@K3](https://forum.convai.com/u/K3)\
**Post date:** [November 25, 2024, 12:14pm UTC](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564/33 "2024-11-25T12:14:37Z")

</div>

This conversation happened on the Convai Discord Server, so this post will be closed.

[Previous page](https://forum.convai.com/t/manual-invoke-a-narrative-trigger-in-unity-using-script/1564.md?page=1)
