Question About Conversation Clips in Unity Timeline

Announcements, support questions, and discussion for the Dialogue System.
Luseya
Posts: 38
Joined: Mon May 29, 2023 6:02 pm

Question About Conversation Clips in Unity Timeline

Post by Luseya »

Hello!

I am using the Dialogue System with the Unity Timeline feature for a cutscene event.

I was just wondering if there is a way to play a conversation using Unity Timeline without the need to add a Continue Conversation clip for every dialogue node? I have a game with lengthy and complex dialogue trees and a lot of cutscenes. I'm still learning, so I'm just wondering if there is an easier way to do this that I may have overlooked.

For my cutscenes, the Player is required to hit the Continue Button in order to progress in the conversations. Right now, I'm using this default sequence:

Timeline(speed, NameOfTimeline, 0);
required Timeline(speed, NameOfTimeline, 1)@Message(Continued)

So my cutscene currently doesn't have any Conversation Clips, but you can still play through the whole dialogue without them. However, since the duration of the conversation depends on Player inputs, and other events in the cutscene depend on the duration of the entire conversation, it looks like I will need to add them after all. But I would like to avoid using 20+ Conversation Clips if possible as that might get a little difficult to manage.

Hopefully I wrote this out clearly enough! Thanks so much for this asset. It's absolutely wonderful :)
User avatar
Tony Li
Posts: 23250
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question About Conversation Clips in Unity Timeline

Post by Tony Li »

Hi,

You're going to need to provide some kind of information at each dialogue entry to let either the conversation or the timeline know when to advance. It's probably simplest overall to use Continue Conversation clips and your default sequence above. This gives you precise control of when each subtitle appears in the timeline. If you want, you can augment the default sequence like this to hide the subtitle text after the player clicks continue:

Code: Select all

Timeline(speed, NameOfTimeline, 0);
required Timeline(speed, NameOfTimeline, 1)@Message(Continued);
required ClearSubtitleText()@Message(Continued);
You could use timeline signals, but that's no less work than dropping in Continue Conversation clips.
Luseya
Posts: 38
Joined: Mon May 29, 2023 6:02 pm

Re: Question About Conversation Clips in Unity Timeline

Post by Luseya »

Hi Tony,

Thank you for getting back to me! I'm still encountering issues when using Conversation Clips.

1) The Timeline keeps stopping after StartConversationClip and doesn't continue even if there are Continue Conversation Clips. Do you know what might cause that?
When I play the Timeline in Scene View, it looks like it's playing through the whole game. But when the cutscene happens in Game view, it stops at the Start Conversation Clip. The conversation starts but doesn't continue (which might be the cause of issue #2 below?)

2) One of the conversations has a PC node (not a response menu, just something the Player character says). The Continue Button pops up for a second then disappears, and then the conversation doesn't proceed. I tested the conversation with a Usable character without using the Timeline, and it works normally there, but when this particular conversation is part of a Timeline, that's when the Continue Button flashes briefly. I tried using the command SetContinueMode(true) to keep it there, but this does not solve the issue.

Thank you for taking the time to help me!
Luseya
Posts: 38
Joined: Mon May 29, 2023 6:02 pm

Re: Question About Conversation Clips in Unity Timeline

Post by Luseya »

I still haven't figured it out but discovered that the issue specifically happens when this Timeline runs after a previous one that also had a conversation. If I tick "Play On Awake," everything is normal. Also, the issue happens no matter what conversation is used in the StartConversationClip.

Timeline#1 starts Conversation#1. At the end of Conversation #1, I use a sequence command to play Timeline#2. Timeline #2 starts, plays an animation in the timeline, but then when it gets to the Start ConversationClip, it plays the first node and immediately stops, and that's when the Continue Button disappears.

I will continue investigating but just wanted to provide those additional details for now!
User avatar
Tony Li
Posts: 23250
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question About Conversation Clips in Unity Timeline

Post by Tony Li »

Hi,

Temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. Then reproduce the issue. Examine the Console logs. It should give you some information about what's going on. More info: Logging & Debugging Tips
Luseya
Posts: 38
Joined: Mon May 29, 2023 6:02 pm

Re: Question About Conversation Clips in Unity Timeline

Post by Luseya »

Hi Tony,

I checked the logs, but everything is showing up as expected; there are no errors or anything out of the ordinary. :(
User avatar
Tony Li
Posts: 23250
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question About Conversation Clips in Unity Timeline

Post by Tony Li »

Hi,

Can you send a reproduction project to tony (at) pixelcrushers.com?
User avatar
Tony Li
Posts: 23250
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question About Conversation Clips in Unity Timeline

Post by Tony Li »

Thanks for sending the reproduction project. To make the timeline pause while it waits for a continue button click and then resume the timeline after clicking continue, you'll need to replace the StandardUIContinueButtonFastForward component with a subclass:

ContinueButtonResumeTimeline.cs

Code: Select all

using UnityEngine;
using UnityEngine.Playables;
using PixelCrushers.DialogueSystem;

public class ContinueButtonResumeTimeline : StandardUIContinueButtonFastForward
{

    public override void OnFastForward()
    {
        if ((typewriterEffect != null) && typewriterEffect.isPlaying)
        {
            typewriterEffect.Stop();
        }
        else
        {
            ResumeTimeline();
        }
    }

    private void ResumeTimeline()
    {
        // Assumes current line's Sequence start with "Timeline(speed, TIMELINENAME, 0)"
        // where "TIMELINENAME" is the name of a PlayableDirector GameObject.
        var sequence = DialogueManager.currentConversationState.subtitle.sequence;
        if (sequence.Contains("Timeline(speed"))
        {
            // Get the timeline name:
            var pos = sequence.IndexOf(',');
            var s = sequence.Substring(pos + 1);
            pos = s.IndexOf(',');
            s = s.Substring(0, pos).Trim();
            // Resume the timeline:
            var subject = SequencerTools.FindSpecifier(s);
            var playableDirector = (subject != null) ? subject.GetComponent<PlayableDirector>() : null;
            if (playableDirector != null)
            {
                if (DialogueDebug.logInfo) Debug.Log($"Dialogue System: Resuming timeline {playableDirector}", playableDirector);
                playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(1);
                //---DialogueManager.standardDialogueUI.HideSubtitle(DialogueManager.currentConversationState.subtitle);
                return;
            }
        }
        // If we don't resume the timeline, just advance the conversation:
        base.OnFastForward();
    }

}
Hook up the continue button's OnClick() to this script's OnFastForward.

This subclass checks the current dialogue entry's Sequence for a command "Timeline(speed, TIMELINENAME..." where TIMELINENAME is the name of the timeline/playable director. It then resumes the timeline instead of continuing the conversation immediately.

You can leave your dialogue entries' Sequence fields blank. Instead, inspect the conversation's properties (Menu > Conversation Properties) and tick Override Display Settings > Camera Settings. Set Sequence to:

Code: Select all

Timeline(speed, TIMELINENAME 0)
where TIMELINENAME is the name of your timeline.

Add Continue Conversation clips when you'd like the conversation to continue.

If you also want to hide the current subtitle text when the player clicks continue, you can uncomment the line in the script that's commented out with "//---".
Luseya
Posts: 38
Joined: Mon May 29, 2023 6:02 pm

Re: Question About Conversation Clips in Unity Timeline

Post by Luseya »

Hi Tony!

Thank you so much! It works exactly as expected with the new component. Thank you so much for taking the time to go through this with me :)
User avatar
Tony Li
Posts: 23250
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question About Conversation Clips in Unity Timeline

Post by Tony Li »

Glad to help!
Post Reply