[HOWTO] How To: Set Up Quests Without Conversations

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 20389
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Set Up Quests Without Conversations

Post by Tony Li »

The Dialogue System's Quest Tutorial shows how to start and complete quests by talking to an NPC.

It's also possible to start and complete quests without conversations. It's slightly more complicated, but when you have done it once it's fairly easy.

To see an example, examine the Dialogue System's DemoScene2. It has a quest named "Enemy Attack". The goal of this quest is to kill 5 enemies.

Each enemy GameObject has an Increment On Destroy component:

Image

When the enemy is killed, it increments a Dialogue System variable named "enemiesKilled". Then it invokes the DialogueSystemTrigger.OnUse method of another GameObject named "Enemies".

The Enemies GameObject has a Dialogue System Trigger that does several things:

Image

In the Conditions section, it requires that the enemiesKilled variable is at least 5 and the Enemy Attack quest is active.

If the Conditions section is true, then the actions in the Actions section will run. The Actions section sets the Enemy Attack quest to success and shows an alert message to the player.


Extra Info: Chained Quests

If you wanted to start another quest as soon as Enemy Attack is successful, you could add an OnExecute() UnityEvent:

Image

Create a new GameObject (for example named "Another Quest"), add a Dialogue System Trigger, and call its DialogueSystemTrigger.OnUse method.

The new GameObject ("Another Quest") will need a Dialogue System Trigger that sets the next quest active:

Image


Extra Info: Automatically Gaining Quest On Start

If you want to give the player a quest as soon as a scene starts, create an empty GameObject. Add a Dialogue System Trigger, and set the Trigger dropdown to OnStart:

Image

In the Conditions section, require that the quest is unassigned. In the Actions section, set the quest active.


Extra Info: Scene Changes

Use these techniques to change scenes.

When Unity changes scenes, it destroys the GameObjects in the outgoing scene. These scene-changing techniques tell Increment On Destroy components that the GameObject is about to be destroyed because of a scene change, so they should not increment their variables in this case.
Post Reply