I'm sure this has been asked a bunch, but I couldn't find it anywhere in the search.
What I'm trying to do is set the quest state from a c# script that's triggered after all the spawned enemies have been killed.
How do I do that?
Set Quest state from script?
Re: Set Quest state from script?
Hi,
To set the quest state from a C# script, use QuestLog.SetQuestState:
A common way to trigger something after all the spawned enemies have been killed is to add an Increment On Destroy and Quest Trigger (or, more generally, Dialogue System Trigger) to each enemy:
To set the quest state from a C# script, use QuestLog.SetQuestState:
Code: Select all
using PixelCrushers.DialogueSystem;
...
QuestLog.SetQuestState("My Quest", QuestState.Success);
- Increment On Destroy will increment a variable. Configure its OnIncrement() event to call the Quest Trigger's OnUse method.
- Set the Quest Trigger's trigger dropdown to OnUse, and set its Condition to require that the variable is greater than or equal to the number of spawned enemies. If so, set the quest state.
Re: Set Quest state from script?
Thanks Tony!
Is there a way at runtime to see what state a quest is in?
Is there a way at runtime to see what state a quest is in?
Re: Set Quest state from script?
Yes, lots of ways.
If you're playing in the Unity editor, open the Dialogue Editor window and click on the Watches tab. Then add a watch on the quest.
If you're in a build, add a Lua Console to the Dialogue Manager. During play, press ~+L to open the Lua Console, and enter:
where My Quest is the name of your quest.
In a script, check QuestLog.GetQuestState("My Quest").
And of course you can always set up a quest log window or quest tracker HUD so the player can check the state of quests.
![Smile :-)](./images/smilies/icon_e_smile.gif)
If you're in a build, add a Lua Console to the Dialogue Manager. During play, press ~+L to open the Lua Console, and enter:
Code: Select all
return CurrentQuestState("My Quest")
In a script, check QuestLog.GetQuestState("My Quest").
And of course you can always set up a quest log window or quest tracker HUD so the player can check the state of quests.