Destroy NPC after conversation.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ujuj04
Posts: 30
Joined: Sun May 21, 2023 7:34 pm

Destroy NPC after conversation.

Post 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?
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Destroy NPC after conversation.

Post 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.
ujuj04
Posts: 30
Joined: Sun May 21, 2023 7:34 pm

Re: Destroy NPC after conversation.

Post 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!
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Destroy NPC after conversation.

Post by Tony Li »

Hi,

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