Page 1 of 1

Using GUI button to trigger dialogue

Posted: Fri Feb 19, 2016 7:20 pm
by ArticulatedPython
Hi,

I can't seem to get a GUI button to access my dialogue database. I am building an FPS-type game, and I want my player to have the option to call back to HQ, and have conversations with his Commander. I have been beating my head against the keyboard trying to get this to work! I've googled, and searched for other help, and I just can't seem to find any (that makes sense to me, at least). Do I use the button OnClick() ( and what should I put?) or is it a line of code I need to use in the Convo Trigger Lua conditions?

Thanks in advance!
AP

Re: Using GUI button to trigger dialogue

Posted: Fri Feb 19, 2016 8:37 pm
by Tony Li
Hi,

Here are a couple ways to do it.


Suggestion 1:
Add a Conversation Trigger component to an empty GameObject. Set the Trigger to OnUse and set up whatever else you need, such selecting the Conversation and optionally assigning the Actor and Conversant.

Use your UI button's OnClick() event. Assign the Conversation Trigger, and select Conversation Trigger > OnUse().


Suggestion 2:
Or, assign the Dialogue Manager to your UI button's OnClick() event instead. Select Dialogue System Controller > StartConversation(string). Type the name of the conversation in the text field.

The drawback of this suggestion is that you can't specify an Actor or Conversant transform. But those are really only necessary if you need the conversation participants to receive "OnConversationStart" and "OnConversationEnd" events (e.g., if they have Set Component Enabled On Dialogue Event components) or if you use sequencer commands that reference the conversation's default speaker (Actor) and listener (Conversant).


Hopefully that'll save some wear and tear on your keyboard (not to mention your head). If you have any questions about this or any other Dialogue System stuff, please don't hesitate to post or email me directly at tony (at) pixelcrushers.com.

Re: Using GUI button to trigger dialogue

Posted: Sat Feb 20, 2016 9:24 am
by ArticulatedPython
Hi Tony,

Thanks so much for the quick reply. I worked through it some more last night, and I realized that a main part of my problem is based on the fact that I am using UFPS with Dialogue System. I can now use the button, and it accesses the convo on the empty GameObject (as you suggested in #1) -- IF another covo is already occurring... I get an error msg saying that another convo is ongoing, so it can't play the convo attached to the button... Which is great-- because now I know the button is accessing the convo.

However, after the dialogue closes, I am "clicking" on the button, but it's not registering being "clicked." I was able to add a line to my UFPS Utility Script to access the cursor in the game window, so I've got that figured out. I posted the info below, in case someone else is having the same problem (accessed: http://opsive.com/assets/UFPS/forum/ind ... -play-mode)

*****************************************
This is an issue introduced by a recent version of Unity 5.3.x. To make the cursor visible in play mode, you need to add one line to "vp_Utility.cs -> LockCursor", where it says:
#if UNITY_EDITOR
Cursor.SetCursor((value ? InvisibleCursor : VisibleCursor), Vector2.zero, CursorMode.Auto);
Cursor.visible = value ? InvisibleCursor : VisibleCursor; // <---------------- ADD THIS LINE -------------
#else
This fix will be included in the next version of UFPS (1.5.3 or higher).
*****************************************

So, now I think it's just some sort of GUI issue... don't know why I can't access it, but I will post the solution once I get it. I am sure it is something simple that I am missing. I just wanted to follow-up, so the next time someone is searching this forum for a solution, they'll be pointed in the right direction!

Cheers,
AP

Re: Using GUI button to trigger dialogue

Posted: Sat Feb 20, 2016 10:32 am
by Tony Li
If it's any help, you can call the methods FPFreezePlayer.Freeze() to freeze the player and show the cursor, and Unfreeze() to release the player and hide the cursor. If you run into a dead end, please feel free to send me an example project. I'd be happy to take a look.