Jumping to Certain Node and Running Scene Events Issues

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
duolazhang
Posts: 10
Joined: Fri Oct 06, 2023 10:54 am

Jumping to Certain Node and Running Scene Events Issues

Post by duolazhang »

Hello everyone,

I am new to coding and using the Pixel Crushers Dialogue System, and I'm seeking help with two issues:

1. Jumping to a Certain Node:
I'm developing an interactive novel game and facing a challenge. When a branch leads to an end node, I've set a button to rewind the story to a specific branching point. However, after clicking this button, the game jumps to the specific node but doesn’t display the expected dialogue options and the timeout countdown, making it seem like the game stops.

Here's the script I used for the button:

using UnityEngine;
using UnityEngine.UI;
using PixelCrushers.DialogueSystem;

public class JumpToDialogueEntryButton : MonoBehaviour
{
public int conversationID;
public int entryID;

public void OnButtonClick()
{
GoToDialogueEntry(conversationID, entryID);
}

private void GoToDialogueEntry(int conversationID, int entryID)
{
var entry = DialogueManager.masterDatabase.GetDialogueEntry(conversationID, entryID);
var state = DialogueManager.conversationModel.GetState(entry);
DialogueManager.conversationController.GotoState(state);
}
}

2. Running Scene Events:
How can I execute a scene event after all sequence commands have finished? Additionally, how can I run an event in the middle of the commands?

BTW, I have the save system attached to the Dialogue

Any advice would be really appreciated!
User avatar
Tony Li
Posts: 20754
Joined: Thu Jul 18, 2013 1:27 pm

Re: Jumping to Certain Node and Running Scene Events Issues

Post by Tony Li »

Hi,
duolazhang wrote: Thu Oct 12, 2023 8:30 am1. Jumping to a Certain Node:
I'm developing an interactive novel game and facing a challenge. When a branch leads to an end node, I've set a button to rewind the story to a specific branching point. However, after clicking this button, the game jumps to the specific node but doesn’t display the expected dialogue options and the timeout countdown, making it seem like the game stops.
Is it possible that the conversation has ended before you call OnButtonClick()? To confirm, temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. If the conversation has ended, the Console will show:

Code: Select all

Dialogue System: Conversation ending.
If the conversation has ended, then DialogueManager.conversationController.GotoState(state) will do nothing. In this case, instead use:

Code: Select all

var conversationTitle = DialogueManager.masterDatabase.GetConversation(conversationID).Title;
DialogueManager.StartConversation(conversationTitle, DialogueManager.currentActor, DialogueManager.currentConversant, entryID);
duolazhang wrote: Thu Oct 12, 2023 8:30 am2. Running Scene Events:
How can I execute a scene event after all sequence commands have finished? Additionally, how can I run an event in the middle of the commands?
Scene events always run as soon as the dialogue entry is shown. To execute a scene event after all sequencer commands, add a blank dialogue entry after the dialogue entry, and move the scene events to that blank dialogue entry. Set the blank dialogue entry's Sequence to: Continue()

If you need to do something in the middle of the sequencer commands, use a sequencer command instead.
duolazhang
Posts: 10
Joined: Fri Oct 06, 2023 10:54 am

Re: Jumping to Certain Node and Running Scene Events Issues

Post by duolazhang »

Hello Tony,

Thank you for your prompt response and the helpful information you provided. I was inspired as you mentioned that "If the conversation has ended, then DialogueManager.conversationController.GotoState(state) will do nothing." I've discovered that the issue was actually caused by the sequence command WaitForMessage(Forever) I have been using. I was trying to stop the Response Timeout Action.

Regarding the timeout settings in the Dialogue Manager, I have an additional question. I've been using the "Custom" option under Response Timeout Action in Input Settings. Most of my conversations have a time limit, which has been working great. However, as the story progresses, certain nodes lead to specific consequences and then present the option to rewind as I mentioned partially above.

In these particular instances, is there a way to either stop or override the timeout action? Alternatively, is it possible to specifically set the timeout action for certain nodes only?

Thank you in advance for your assistance and guidance!
User avatar
Tony Li
Posts: 20754
Joined: Thu Jul 18, 2013 1:27 pm

Re: Jumping to Certain Node and Running Scene Events Issues

Post by Tony Li »

Hi,

If you want to prevent a response menu from having a timeout value altogether, in the preceding dialogue entry use the SetTimeout(0) sequencer command. This will set the timeout value to 0, which means no timeout.

On the other hand, if you want the menu to time out but not to do your regular custom timeout handler, you'll need to handle that in your custom timeout handler. For example, you could define a custom field and set it in the preceding dialogue entry. In your timeout handler, check for this field.

Example: Let's say you add a define a Boolean field named "Timeout To First Response" that's false by default. You could check if it's true like this:

Code: Select all

DialogueManager.customResponseTimeoutHandler = OnMenuTimeout;
...
void OnMenuTimeout()
{
    bool useFirstResponse = Field.LookupBool(DialogueManager.currentConversationState.subtitle.dialogueEntry.fields, "Timeout To First Response");
    if (useFirstResponse)
    {
        DialogueManager.standardDialogueUI.OnClick(DialogueManager.currentConversationState.pcResponses[0]);
    }
    else
    {
        // (Your regular custom timeout handler code here)
    }
}
duolazhang
Posts: 10
Joined: Fri Oct 06, 2023 10:54 am

Re: Jumping to Certain Node and Running Scene Events Issues

Post by duolazhang »

Thanks a lot! There’s so much to learn!
User avatar
Tony Li
Posts: 20754
Joined: Thu Jul 18, 2013 1:27 pm

Re: Jumping to Certain Node and Running Scene Events Issues

Post by Tony Li »

Glad to help!
Post Reply