Player input "code" for quest

Announcements, support questions, and discussion for the Dialogue System.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Player input "code" for quest

Post by supadupa64 »

Is there way for the player to input a code for a quest during a dialogue?

Example: NPC says, "give me the code and I'll give you this gem." There is a space for the player to input a code.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Player input "code" for quest

Post by Tony Li »

Yup. Take a look at the Computer Terminal conversation in the Feature Demo. It runs as a conversation. To log into the terminal, you have to enter a password. If you enter the correct code ("dominate"), the conversation progresses. There's also a separate computer terminal example that might be easier to take apart since it doesn't have all the other conversations and barks that the Feature Demo has. The key is using the TextInput() sequencer command.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Player input "code" for quest

Post by supadupa64 »

I tried to add a NGUITextFieldUI.cs script to my ui object but when I import the third party NGUI 3.x Support package with the scripts I got compiler errors so I had to revert back.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Player input "code" for quest

Post by Tony Li »

Hi,

What GUI system are you using for your dialogue UI? (In other words, what's assigned to your Dialogue Manager's Dialogue UI field? UnityUIDialogueUI, UnityDialogueUI, NGUIDialogueUI, etc.) You only need to import the NGUI support package if you're using NGUI. If your project doesn't have NGUI, the support package won't work.

The Terminal conversation in the Feature Demo uses the legacy GUI system. It doesn't use NGUI.

If you're using UnityUIDialogueUI (the new UI system), text field UIs are built into all of the prefabs. You can examine any of them to see how to set up your own.

If you're using UnityDialogueUI (the legacy GUI system), examine the default prefab in Prefabs/Legacy Unity GUI Prefabs/Default/Resources.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Player input "code" for quest

Post by supadupa64 »

Here's what I have for my UI. I don't know if this is the right area or not. I can't see the conversation in the demo, so that doesn't work. I figure it's pretty simple to set this up, I'm just not seeing it.
UIinput.jpg
UIinput.jpg (127.67 KiB) Viewed 2436 times
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Player input "code" for quest

Post by Tony Li »

Hi,

Since you're using the Necromancer Dialogue UI (legacy Unity GUI), you should put a legacy Unity GUI "Text Field UI" in it. Don't add a separate new Unity UI Canvas and dialogue UI. (Technically you can do this by using an Override Dialogue UI component, but I don't think that's what you want in this case.)

Here's a version of the Necromancer Dialogue UI that has a Text Field UI: NecroWithTextInput_2016-05-07.unitypackage

It imports as Assets > Dialogue System > Prefabs > Legacy Unity GUI Prefabs > Necromancer > Necromancer Dialogue UI with TextInput.

It has a new child GameObject named Text Field UI. I left the Dialogue Window GameObject active so you can easily see the Text Field UI and customize its appearance to your liking. Then deactivate Dialogue Window so it doesn't obscure your Game view as you're editing your scene.

Or, if you already have a custom dialogue UI, you can just move the Text Field UI to your custom dialogue UI. Make sure it's a child of Dialogue Window.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Player input "code" for quest

Post by supadupa64 »

Here's what I have right now. Input is default off center? I can't figure out how to move it. I think I'm missing a step. If I enter a password it goes to the next dialogue node, but doesn't register if it's correct or incorrect. :shock: I guess this is set up to choose the label or no label?
labeloffcenter.jpg
labeloffcenter.jpg (75.36 KiB) Viewed 2430 times
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Player input "code" for quest

Post by Tony Li »

I didn't know how you'd want to position the input field, so I left it entirely up to you.

For checking the password, I recommend looking at Assets > Dialogue System > Examples > Computer Input Loop. In particular, notice the <Delay Condition Evaluation> node. Since the Dialogue System normally evaluates conditions one level ahead, this "buffer" node delays evaluation of the player's input until after the player has entered it.

Image
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Player input "code" for quest

Post by supadupa64 »

How can I view the conversations in the demo? All I can ever see are my own.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Player input "code" for quest

Post by Tony Li »

Can you open the scene in the folder Assets > Dialogue System > Examples > Computer Input Loop?

If you play this scene, you'll get an idea of how it works.

Then inspect the scene's Dialogue Manager, and click on the Dialogue System banner to open the scene's database in the Dialogue Editor.
Post Reply