Page 1 of 1

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

Posted: Sat Feb 16, 2019 4:55 am
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

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

Posted: Sat Feb 16, 2019 8:26 am
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.