Hi,
That code will work to count down a patience meter. But when it hits zero, what do you do?
[EDIT: It just occurred to me that your dialogue entry might have a Condition that checks the Patience variable. Conditions are only checked before dialogue entries are shown; they're not evaluated continuously while the entry is onscreen.]
The easiest solution might be to use a different approach. You can set a
Response Timeout in the Dialogue Manager's
Input Settings. If it's non-zero, the dialogue UI will take some action. The default action auto-selects the first response. You could make it something like "[say nothing]".
If you don't want to auto-select the first response, you can change the action to End Conversation, and then add a script that has an
OnConversationTimeout method. In this method, you can restart the conversation at a certain point, either by manually calling DialogueManager.StartConversation with a specific entry ID or by setting a variable that the conversation could check as a condition. Or you could make the NPC bark, instead of restarting the conversation, and walk away.
(BTW, if you don't want to show the timer while it's counting down, you can add a CanvasGroup to it and set its Alpha to zero.)
If you don't want to use the built-in timer, you can manually change the conversation to another dialogue entry by using code similar to below:
Code: Select all
// Get the current conversation's ID:
var conversationID = DialogueManager.CurrentConversationState.subtitle.dialogueEntry.conversationID;
// This is the dialogue entry we want to jump to when impatient:
var entryID = 42; // (Replace with your number/algorithm.)
// Get the dialogue entry:
var impatientEntry = DialogueManager.MasterDatabase.GetDialogueEntry(conversationID, entryID);
// Get the conversation state for that entry:
var impatientState = DialogueManager.ConversationModel.GetState(impatientEntry);
// Change the conversation to that state:
DialogueManager.ConversationController.GotoState(impatientState);
Those are just some ideas off the top of my head. If they don't help, let me know. There's always more than one way to skin a cat.
EDIT: Another idea is to write a custom sequencer command to jump to a specified entry, which is actually really easy using the provided template. The command could fire at a specified time, like this:
- Dialogue Text: "So what do you say?"
- Response Menu Sequence: GotoEntry(42)@5
The entry above will show "So what do you say?". During the response menu, it will play the sequence above. If the player selects a response before 5 seconds are up, it will cancel the sequence, so GotoEntry will never fire.