Deactivate usable component [if some condition is met] or [if event is raised]

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
onpocket
Posts: 13
Joined: Fri Feb 01, 2019 5:04 am

Deactivate usable component [if some condition is met] or [if event is raised]

Post by onpocket »

Hello, i don't know if this was already asked, but since i could not find anything related to this topic here i go:

Is it possible to turn off usables, after such event in a quest? For example, after the player answers correctly to a question the said NPC would get its usable component disabled.

Sorry if this is a basic question, or if it was already answered, yesterday i struggled a lot trying ti find how to do such thing (without looking into code).

Best regards,
João Aguizo
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Deactivate usable component [if some condition is met] or [if event is raised]

Post by Tony Li »

Hi João,

Use the SetEnabled() sequencer command to disable the NPC's Usable component. For example, if the NPC says this line:
  • Dialogue Text: "Correct. You do not need to talk to me again."
then you can add a Sequence:
  • Dialogue Text: "Correct. You do not need to talk to me again."
  • Sequence: {{default}}; SetEnabled(Usable,false)
SetEnabled(Usable,false) disables the speaker's Usable component (that is, the NPC's component in this case). If you need to disable another GameObject's Usable, you can specify the GameObject name as a third parameter, such as: SetEnabled(Usable,false,Wizard).

The {{default}} tells the dialogue entry to also play the Dialogue Manager's Default Sequence.

If you always want to disable the Usable after starting any conversation, you can configure the Dialogue System Trigger to do this. Add Action > OnExecute() event. Configure the event to disable the Usable component.

If you need saved games to remember whether this component was enabled or disabled, add an Enabled Saver component to the NPC.
Post Reply