Page 1 of 1

Destroy NPC after conversation.

Posted: Sun May 28, 2023 12:48 pm
by ujuj04
Is there a convenient way to destroy an NPC after the convo? Or should I assign a script that will activate when the conversation is over that destroys this instance?

Re: Destroy NPC after conversation.

Posted: Sun May 28, 2023 2:51 pm
by Tony Li
Hi,

If it's sufficient to deactivate the GameObject, you can add a Dialogue System Events component to the NPC. Configure the OnConversationEnd() event to deactivate the GameObject.

If you must destroy it, you could add a script with an OnConversationEnd(Transform) method to it, and destroy the GameObject in that method.

Re: Destroy NPC after conversation.

Posted: Tue May 30, 2023 9:14 pm
by ujuj04
Hey thanks for the suggestion above. It worked perfectly in my case. However, now in a different scenario I need to deactivate the object only after a specific dialogue line (I have a key that could be collected and want the object on the scene to deactivate only if the player chooses option "Take key"). Thanks in advance!

Re: Destroy NPC after conversation.

Posted: Tue May 30, 2023 9:18 pm
by Tony Li
Hi,

Use the SetActive() sequencer command, or a scene event (in the dialogue entry inspector's OnExecute() section).