OnConversationStart and OnConversationLine

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

OnConversationStart and OnConversationLine

Post by joeylu »

Tony, based on its naming, I thought OnConversationStart is triggered before any OnConversationLine is triggered in a conversation life cycle, but it is not the case, can you explain a bit of these two in the conversation life cycle?
I'm trying to initializing some object whenever a conversation is started, currently I put my logics in OnConversationStart(), but I realized that OnConversationLine might be triggered before OnConversationStart, so sometimes it will throw me null errors, maybe there's another event I should look for instead OnConversationStart? tks
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

Re: OnConversationStart and OnConversationLine

Post by joeylu »

also, another question, for instance, I set dialogue system controller continue button to always, and I want to play a "talking" animation while actor is on a dialogue node. I use OnConversationLine to do the logic and it works perfectly if continue button is not "always", but in "always" mode, I need to manually stop the "talking animation" after a while in a dialogue node, otherwise, if player don't click the continue button, the "talking animation" will keep looping and it is kind weired.
so my question is, is there any event that I can use to get the subtitle playing time? something like getting (subtitle chars per second * total characters in current dialogue node), so when it's got finished, I can stop the "talking animation" even it is still in the same dialogue node.
User avatar
Tony Li
Posts: 21049
Joined: Thu Jul 18, 2013 1:27 pm

Re: OnConversationStart and OnConversationLine

Post by Tony Li »

When a conversation starts, it first creates an initial model of the conversation by processing all links from the conversation's <START> node. To do this, it will call OnConversationPrepareLine on each node linked from <START>.

If the initial model has at least one node that's currently valid, it will start the conversation, and OnConversationStart will be called.

More details: [HOWTO] Conversation Execution Order


A common way to handle "talking" animations is to use sequencer commands. Let's say all of your characters have "talking" and "idle" animator states. You could set the Dialogue Manager's Camera & Cutscene Settings > Default Sequence to:

Code: Select all

AnimatorPlay(talking);
required AnimatorPlay(idle)@Message(Typed)
When the dialogue entry node starts, the first line will immediately play the speaker's "talking" animation.

When the typewriter effect finishes typing, it will send the sequencer message "Typed". The second line listens for this message. When it receives the message, it will play the "idle" animation. The "required" keyword guarantees that the second line will play even if the player clicks the continue button to advance the conversation before the typewriter has finished typing.
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

Re: OnConversationStart and OnConversationLine

Post by joeylu »

ok, tks for the reply, so the "Start" node will be played before OnConversationStart is executed, can I filter out the "Start" node in OnConversationPrepareLine method? something like if (dialogueEntry.id == 0) ?
User avatar
Tony Li
Posts: 21049
Joined: Thu Jul 18, 2013 1:27 pm

Re: OnConversationStart and OnConversationLine

Post by Tony Li »

Yes, that's fine. ID 0 is always the <START> node.
Post Reply