How to change animation when audio ends?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ludm
Posts: 11
Joined: Tue May 05, 2020 3:11 pm

How to change animation when audio ends?

Post by ludm »

Hello,
Here is my setting:
I have a dialogue in which the NPC has audio recorded voice assigned with code in each node:

Code: Select all

AudioWait(Audio/my-text).
I have both conversation and idle animation for the NPC
I use the following default sequence:

Code: Select all

AnimatorPlay(Conversation,npc_body);
required AnimatorPlay(Idle,npc_body)@{{end}}
I know that end is based on the subtitle Chars Per Second setting.

Is there a solution to play the idle animaition when the audio file is ended ?
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to change animation when audio ends?

Post by Tony Li »

Hi,

Yes. Change your Sequence to:

Code: Select all

AnimatorPlay(Conversation,npc_body);
AudioWait(Audio/my-text)->Message(DoneTalking);
required AnimatorPlay(Idle,npc_body)@Message(DoneTalking)
BTW, if you have a lot of dialogue entries, you might want to look into entrytags. (Tutorial) Then you can set the Dialogue Manager's Default Sequence to:

Code: Select all

AnimatorPlay(Conversation,npc_body);
AudioWait(entrytag)->Message(DoneTalking);
required AnimatorPlay(Idle,npc_body)@Message(DoneTalking)
and leave your dialogue entries' Sequence fields blank.
ludm
Posts: 11
Joined: Tue May 05, 2020 3:11 pm

Re: How to change animation when audio ends?

Post by ludm »

Thank you that works great.

I have another question:
I have a toggle button for subtitle in the scene. Would it be possible to skip continue button when subtitle are hidden (go to the next audio automatically)?

Here is the code now:

Code: Select all

SetContinueMode(true);
AnimatorPlay(Conversation,girlbody);
AudioWait(Audio/e0)->Message(DoneTalking);
required AnimatorPlay(Idle,girlbody)@Message(DoneTalking)

Code: Select all

AnimatorPlay(Conversation,girlbody);
AudioWait(Audio/e1)->Message(DoneTalking);
required AnimatorPlay(Idle,girlbody)@Message(DoneTalking)
Last edited by ludm on Wed Oct 21, 2020 11:29 am, edited 1 time in total.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to change animation when audio ends?

Post by Tony Li »

If you're talking about a toggle button that toggles whether subtitles are shown or not, configure this button to set the values of DialogueManager.displaySettings.subtitleSettings.showNPCSubtitlesDuringLine and showPCSubtitlesDuringLine.

If the corresponding value is false, then it won't show the subtitle or continue button, and it should skip right ahead, playing the node's Sequence without a subtitle.
ludm
Posts: 11
Joined: Tue May 05, 2020 3:11 pm

Re: How to change animation when audio ends?

Post by ludm »

Thank you, it is nearly ok. The dialog continues, but at step #3 the animation plays Idle and not Conversation. The animation is Conversation again at step #4.

#1

Code: Select all

AnimatorPlay(Conversation,girlbody);
SALSA(Audio/e1);
#2

Code: Select all

SetContinueMode(true);
SALSA(Audio/e2)->Message(DoneTalking2);
required AnimatorPlay(Idle,girlbody)@Message(DoneTalking2)
;
#3

Code: Select all

AnimatorPlay(Conversation,girlbody);
SALSA(Audio/e3)->Message(DoneTalking3);
required AnimatorPlay(Idle,girlbody)@Message(DoneTalking3)
#4

Code: Select all

SetContinueMode(false);
AnimatorPlay(Conversation,girlbody);
SALSA(Audio/e4)->Message(DoneTalking4);
required AnimatorPlay(Idle,girlbody)@Message(DoneTalking4)
If I set 7 dialogues with a SetContinueMode(true) on the 1 st one, it will play Idlle on step #2 #4 and #7.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to change animation when audio ends?

Post by Tony Li »

Hi,

Based on the sequences above, I don't see anything wrong. Would it be possible for you to send me a reproduction project?
Post Reply