Destroying an NPC Object Within Conversation [Solved]

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
pegassy
Posts: 135
Joined: Sat Mar 17, 2018 8:07 pm

Destroying an NPC Object Within Conversation [Solved]

Post by pegassy »

Hello,

I am looking for a way to disable or destroy an NPC object during a conversation if a particular conversation option is chosen. I am using Opsive's TPC. Is there a way with or without integration with Opsive's TPC to destroy the NPC object?

Thank you.
Last edited by pegassy on Fri Apr 06, 2018 11:43 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Destroying an NPC Object Within Conversation

Post by Tony Li »

Hi,

Use the SetActive() sequencer command. For example:
  • Dialogue Text (NPC): "Don't press this button."
    • Dialogue Text: (Player) "[press button]"
    • Sequence:

      Code: Select all

      Audio(Explosion);
      SetActive(Building,false)
If you want to remember in saved games that the Building has been deactivated, use a dialogue database variable and the Persistent Active Data component. For example, add this sequencer command:
  • Dialogue Text (NPC): "Don't press this button."
    • Dialogue Text: (Player) "[press button]"
    • Sequence:

      Code: Select all

      Audio(Explosion);
      SetActive(Building,false);
      SetVariable(DestroyedBuilding,true)
and then configure the Persistent Active Data component with the following values:
  • Target: Building
  • Condition > Lua Conditions: Variable["DestroyedBuilding"] == true
Eldinen
Posts: 1
Joined: Wed Mar 28, 2018 11:49 am

Re: Destroying an NPC Object Within Conversation

Post by Eldinen »

You can use SendMessage(DestroyGameObject,,yourObject) then the gameobject yourObject must have a script with a method DestroyGameObject like this:

https://docs.unity3d.com/ScriptReferenc ... stroy.html

This destroy the gameobject, you cannot recovery it
pegassy
Posts: 135
Joined: Sat Mar 17, 2018 8:07 pm

Re: Destroying an NPC Object Within Conversation

Post by pegassy »

Thank you for the super helpful posts. I will try it. This is opens up many possibilities from within the dialogues!
pegassy
Posts: 135
Joined: Sat Mar 17, 2018 8:07 pm

Re: Destroying an NPC Object Within Conversation

Post by pegassy »

It worked like a charm. Thanks a lot.
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Destroying an NPC Object Within Conversation [Solved]

Post by Tony Li »

Glad to help!
Post Reply