Pause and resume the Timeline

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Kamotachi
Posts: 44
Joined: Fri Nov 29, 2019 9:03 pm

Pause and resume the Timeline

Post by Kamotachi »

Hi!
I'm using the dialogue system a lot! :D
I am doing a cinematic using a Timeline.
I would like to pause the timeline when a dialog message appears.
When the message is completely written, press the continue button, and resume the cinematic.

I think probably I must use the sequencer: Timeline() , right?

Something like... :

SetContinueMode(false)_____________ remove the continue button
Timeline(pause,nameOfTimeline);_______ pause the timeline
fully written message ->Message(written);__ ( how do I this? send a message when the text is completed) :?:
SetContinueMode(true)@Message(written)______________ active the continue button

Timeline(resume,nameOfTimeline);_______ (how resume the timeline when press continue?) :?:

Thanks in advance!
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Pause and resume the Timeline

Post by Tony Li »

Hi,

Try setting your Sequence to:

Code: Select all

SetContinueMode(false); // Remove continue button
Timeline(speed, nameOfTimeline, 0); // Pause timeline (use speed to pause)
SetContinueMode(true)@Message(Typed) // Active continue button upon special message 'Typed'
required Timeline(speed, nameOfTimeline, 1)@Message(Continued); // Resume timeline on continue
Notes:
  • It's best to pause the timeline by setting its speed to zero. This is because of a quirk in Timeline. If you use the timeline's Pause() and Resume() methods, it replays all clips at the point where it was paused. Setting the speed to zero doesn't do this.
  • When the typewriter effect finishes, it sends the special message 'Typed'.
  • The last line waits for a fake message named 'Continued'. I just made that message up for this reply. It doesn't have any meaning in the Dialogue System, and nothing will ever send it, so it will wait forever for this message. However, the 'required' keyword guarantees that it will run anyway when the player clicks the continue button.
Kamotachi
Posts: 44
Joined: Fri Nov 29, 2019 9:03 pm

Re: Pause and resume the Timeline

Post by Kamotachi »

Thanks a lot!
Mission complete! :mrgreen:


So... :roll: now I need to wait a range of time between messages. For example... I press Continue, timeline runs, and in the second 11 ( for example) appear the next message.

Which is the best way?, I'm thinking on create a new message between the others, but in blank, and put Delay() in the sequencer, maybe?

I've seen that an Alert track can be added in the Timeline, could it be used for this?

Sorry to ask so many questions, thank you very much Tony.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Pause and resume the Timeline

Post by Tony Li »

Let's say the order of events is this:
  • 0:00 - 0:02: Timeline runs
  • 0:02: Dialogue entry 1 appears; timeline speed=0. When player clicks continue, timeline speed returns to 1.
  • 0:02-0:11: Timeline runs
  • 0:11: Dialogue entry 2 appears; timeline speed=0. When player clicks continue, timeline speed returns to 1.
  • 0:11-0:20: Timeline runs...
There are two ways you can set that up:

1. Configure the dialogue entries so they all link from the <START> node and don't have any child links. Use Start Conversation clips to show each entry, specifying the entry ID.

2. Or change your setup slightly. This approach is more complicated to set up, but it lets you write your conversation sequentially (entry 1 links to entry 2; entry 2 links to entry 3, etc.).
  • Set the Dialogue Manager's Subtitle Settings > Continue Button mode to Always.
  • Configure the conversation's first node's Script to set a variable to the timeline name. Example:

    Code: Select all

    Variable["nameOfTmeline"] = "My Timeline"
  • Don't use continue buttons in the traditional way. Leave the subtitle panel's Continue Button field unassigned.
  • Give your subtitle panel and continue button unique names. For example, name the continue button "Resume Button". Configure its OnClick() event to do two things:
    • Run a Dialogue System Trigger with Actions > Play Sequence: Timeline(speed, [var=nameOfTimeline], 1)
    • Call the subtitle panel's Close() method.
  • Change the entries' Sequence to:

    Code: Select all

    SetActive(Resume Button, false); // Hide Resume button
    Timeline(speed, nameOfTimeline, 0); // Pause timeline (use speed to pause)
    SetActive(Resume Button, true)@Message(Typed) // Show Resume Button upon special message 'Typed'
  • In your timeline, use a Start Conversation clip to start the conversation. At the 0:11-second mark, use a Continue Conversation clip to show the next entry, and so on.
Kamotachi
Posts: 44
Joined: Fri Nov 29, 2019 9:03 pm

Re: Pause and resume the Timeline

Post by Kamotachi »

Wow, you save me again.
All goes perfect !!!
I've no words to gratefull. ^^!!!
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Pause and resume the Timeline

Post by Tony Li »

Happy to help!
Post Reply