Press a button to complete quest

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ricjonsu098
Posts: 45
Joined: Sat Jul 30, 2016 8:37 am

Press a button to complete quest

Post by ricjonsu098 »

Hello, I'm new to Dialogue System.

So here's the scenario. On Run-time, a quest will appear which states that "Press W to walk forward"

And my problem is, how can I make it so that the quest will be finished when the W button is pressed? Thanks
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Press a button to complete quest

Post by Tony Li »

Hi,

Thanks for using the Dialogue System!

You could put a trigger collider in front of the player and add a Quest Trigger component. Set the Trigger property to OnTriggerEnter, and set the Quest State to success.

Another way is to write a script that listens for Input.GetKeyDown(KeyCode.W) and calls QuestLog.CompleteQuest("your quest name"). Or you can use an equivalent visual scripting action (such as in PlayMaker) if you don't want to write a script.
ricjonsu098
Posts: 45
Joined: Sat Jul 30, 2016 8:37 am

Re: Press a button to complete quest

Post by ricjonsu098 »

thanks a lot. I have another question, what makes the game pause when the main menu is opened? Like the one's in the feature demo/quest example, whenever I open the menu (ESC button), the game stops/pauses. But when I tried to put the menu in my scene, whenever I press ESC, I can still control the camera and the player.
ricjonsu098
Posts: 45
Joined: Sat Jul 30, 2016 8:37 am

Re: Press a button to complete quest

Post by ricjonsu098 »

and also how can I start another dialogue (actually, it's a monologue) after I finished a quest? Here's the scenario.

at runtime, a monologue runs, then after that a quest has started. I press W, then the quest finishes. After that I want another monologue to run

Here's how it's supposed to run:
Game Start > Monologue: Guide me to my house > (after monologue) Quest: Press W to start > *Presses W* > Quest finishes > Monologue: Good! Now next please.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Press a button to complete quest

Post by Tony Li »

ricjonsu098 wrote:thanks a lot. I have another question, what makes the game pause when the main menu is opened? Like the one's in the feature demo/quest example, whenever I open the menu (ESC button), the game stops/pauses. But when I tried to put the menu in my scene, whenever I press ESC, I can still control the camera and the player.
The Feature Demo and Quest Example scenes use a script named "FeatureDemo". This script was originally designed just to drive the demo scenes, but some people have modified it to actually run their games' main menus. In this script, if you press ESC it sets Time.timeScale to 0 to pause the game. If your camera and control scripts respect Time.timeScale, they should also pause.

If you want a more full-featured and robust menu system, the Dialogue System Extras page has a free Dialogue System Menu Template package. This package has Unity Events where you can assign actions when pausing and unpausing the game, similar to how you can assign actions to a Unity UI Button's OnClick event.
ricjonsu098 wrote:and also how can I start another dialogue (actually, it's a monologue) after I finished a quest? Here's the scenario.

at runtime, a monologue runs, then after that a quest has started. I press W, then the quest finishes. After that I want another monologue to run

Here's how it's supposed to run:
Game Start > Monologue: Guide me to my house > (after monologue) Quest: Press W to start > *Presses W* > Quest finishes > Monologue: Good! Now next please.
The Tutorial Example scene may be a good example to follow. The entire tutorial runs in a single conversation that stays active while waiting for the player to complete tutorial objectives.

Otherwise, if you don't want to do that, you can add a Dialogue System Events component to the Dialogue Manager. In the "Quest Events" section, add an action to the OnQuestStateChange event. You could point this to a new Conversation Trigger that's set to OnUse. Add a Condition to the Conversation Trigger that the first quest is in the success state.
Post Reply