Page 1 of 1

OnConversationStart and OnConversationLine

Posted: Tue Jan 17, 2023 3:47 am
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

Re: OnConversationStart and OnConversationLine

Posted: Tue Jan 17, 2023 6:32 am
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.

Re: OnConversationStart and OnConversationLine

Posted: Tue Jan 17, 2023 11:15 am
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.

Re: OnConversationStart and OnConversationLine

Posted: Wed Jan 18, 2023 8:42 am
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) ?

Re: OnConversationStart and OnConversationLine

Posted: Wed Jan 18, 2023 9:21 am
by Tony Li
Yes, that's fine. ID 0 is always the <START> node.