Can I play the "Idle" and "Talking" animation using Dialogue System Events Component?

Announcements, support questions, and discussion for the Dialogue System.
gdbaradit
Posts: 14
Joined: Mon Sep 09, 2019 1:25 pm

Can I play the "Idle" and "Talking" animation using Dialogue System Events Component?

Post by gdbaradit »

This is my Issue:


If my character goes running against the NPC and press the "Talking key" (In my case, F) the character will keep playing the Running animation. I tried using the solution shown in the Triggers and Interactions video, but it didn't work.

Plus, since I'm using shaders for 2D sprites, I have 2 animations for every state: Idle-right, Idle-left, Talking-right, Talking-Left, etc.


How can I get my character to play the idle/talking animations, plus considering the direction they're talking to?


Bonus Question: Everytime I start the game, the Writer Effect Audio plays twice and then stops for reasons unknown to me.... What could it be?
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can I play the "Idle" and "Talking" animation using Dialogue System Events Component?

Post by Tony Li »

Hi,
gdbaradit wrote: Thu Sep 12, 2019 5:57 pmIf my character goes running against the NPC and press the "Talking key" (In my case, F) the character will keep playing the Running animation. I tried using the solution shown in the Triggers and Interactions video, but it didn't work.
The solution is going to be specific to your character. Identify what makes the Running animation play.
  • If it's a script, you will need to use Dialogue System Events to disable the script during conversations.
  • If it's an animator parameter such as Speed, you may be able to use Dialogue System Events by assigning the Animator to the event.
  • If not, you can use a Dialogue System Trigger set to On Conversation Start. Select Add Action > Play Sequence. Then use one of the Animator***() sequencer commands in the Sequence field to set the parameter to a value that makes the Running animation stop.
It may require a combination. Feel free to post more details about your character here, or send an example project to tony (at) pixelcrushers.com if you want me to take a look directly.
gdbaradit wrote: Thu Sep 12, 2019 5:57 pmPlus, since I'm using shaders for 2D sprites, I have 2 animations for every state: Idle-right, Idle-left, Talking-right, Talking-Left, etc.

How can I get my character to play the idle/talking animations, plus considering the direction they're talking to?
I recommend tackling it in two steps. In the first step, get the character talking regardless of direction. Try setting the Dialogue Manager's Camera & Cutscene Settings > Default Sequence to:

Code: Select all

AnimatorPlay(Talking-right);
required AnimatorPlay(Idle-right)@{{end}}
(Make sure the spelling and capitalization exactly matches your animator states.)

This will make the characters play Talking-right as soon their line starts. After a duration based on the text length, they will play the Idle-right animation.

If only your player has these animations, you can set Default Player Sequence instead.

If you have questions about sequences, watch at least part 1 of the Cutscene Sequence Tutorials. Parts 2 & 3 are useful, too. You can probably skip the rest for now.

---

Once you have that working, here's a discussion about playing animations with directions:

Personally, I think it might be easier to let the Animator know which animations to play. Let's say you have an animator parameter named "Left". When the character is facing left, the parameter is true. When the character is facing right, the parameter is false. Then you can add trigger parameters named Idle and Talk. If Talk is triggered and Left is true, transition to Idle-Left. If Talk is triggered and Left is false, transition to Idle-Right. This way, as long as you've been setting the Left parameter when the character turns left or right, you can just set the Talk trigger to make the character talk in the appropriate direction. Then set the Default Sequence to:

Code: Select all

AnimatorTrigger(Talk);
required AnimatorTrigger(Idle)@{{end}}
The Dialogue System doesn't need to know anything about left/right direction in this case.

If you don't want to do that, and if you want to make the Dialogue System handle it, you can define and set a Dialogue System variable to the player's current direction. In C# script, you can do something like this:

Code: Select all

PixelCrushers.DialogueSystem.DialogueLua.SetVariable("Dir", "left"); // Player is facing left.
In this case, I'll assume that you're keeping the Dialogue System variable "Dir" up to date as the player turns left & right.

Then set the Default Player Sequence to:

Code: Select all

AnimatorPlay(Talking-[var=Dir]);
required AnimatorPlay(Idle-[var=Dir])@{{end}}
gdbaradit wrote: Thu Sep 12, 2019 5:57 pmBonus Question: Everytime I start the game, the Writer Effect Audio plays twice and then stops for reasons unknown to me.... What could it be?
You're talking about the typewriter effect on your subtitle panels' text elements, right? If so, inspect the Audio Source component on the same GameObject and untick Play On Awake. If the GameObject doesn't have an Audio Source component, add one and untick Play On Awake.
gdbaradit
Posts: 14
Joined: Mon Sep 09, 2019 1:25 pm

Re: Can I play the "Idle" and "Talking" animation using Dialogue System Events Component?

Post by gdbaradit »

Toni thank you so much for your time and reply.
If it's an animator parameter such as Speed, you may be able to use Dialogue System Events by assigning the Animator to the event.
THIS! This would solve everything.

One problem I had was that I have an "Animation-States" script in charge of organizing and setting the parameters in the animator for the states, and THAT didnt let me change the parameters. Not even manually.

Using the Dialogue System Events I can disable the "Animation-States" script and enable it back when the conversation is over.

Plus with the Dialogue System Trigger I can set the parameters BUT it doesn't let me differentiate between when the character is speaking a dialogue line (talking animation) and when the character is just in the conversation listening. (idle)


How can I set the parameters using the Dialogue System Events => Conversation Events? I can't seem to find the option to Set the floats, int and bools parameters. If I can do that, I can easily set the animation I want in the correct direction.
Image




One last question: Since I'm going to use bubbles for conversations, Is there a way to make sure a Dialogue Line appears over the head of a specific character? In my case besides giving the player the chance to choose the answer I want it to appear over the head of the character like he's talking (Animation and everything)
Image



This is what I have so far. It's a situation similar to the Robot and Boxes from the Trigger and Interaction tutorial video:




Again, thank you so much for your time and ideas. I'll be checking the Cutscenes Sequence Tutorials. I tried to study them but I got confused to be honest, but I really want to master it since I'm tryign to make a story driven game.

THANKS!!!!!!!
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can I play the "Idle" and "Talking" animation using Dialogue System Events Component?

Post by Tony Li »

Hi,
gdbaradit wrote: Fri Sep 13, 2019 12:41 amHow can I set the parameters using the Dialogue System Events => Conversation Events?
You'll need to use a Dialogue System Trigger with an AnimatorFloat() sequencer command like at the very bottom of the Interaction Tutorial:
Image

While you can assign an Animator component to a UnityEvent such as the Dialogue System Events component's OnConversationStart(), the Animator component doesn't expose a method to set float parameters. It only lets you control trigger parameters.

Fortunately, you can use sequencer commands to set float parameters, saving you from having to do any scripting. If I can clarify anything with sequencer commands, please let me know.
gdbaradit wrote: Fri Sep 13, 2019 12:41 amOne last question: Since I'm going to use bubbles for conversations, Is there a way to make sure a Dialogue Line appears over the head of a specific character?
Just like with FatRat, add a Dialogue Actor component to the player. Assign a bubble subtitle panel and bubble menu panel. If you haven't already, take a look at the BubbleSubtitleExample scene (direct download) available on the Dialogue System Extras page. The panels don't actually have to look like bubbles. You can get rid of the bubble image and change the text to a chunky pixel font if you want more of a Monkey Island look. Come to think of it, if you want the Monkey Island look, only assign a bubble subtitle panel to the player; leave the menu panel setting at Default so the menu appears at the bottom of the screen.

(p.s. - Nice art style! )
gdbaradit
Posts: 14
Joined: Mon Sep 09, 2019 1:25 pm

Re: Can I play the "Idle" and "Talking" animation using Dialogue System Events Component?

Post by gdbaradit »

Hi Toni! Thanks for your time

This is the result of your last help:
You'll need to use a Dialogue System Trigger with an AnimatorFloat() sequencer command like at the very bottom of the Interaction Tutorial:
I learnt how to use sequence commands in the conversation by adding them into the sequence area

BUT, even though when I add the commands they actually work like I want (for example if I want to set the "talking" parameter to "True" I use AnimatorBool(talking, true) and it DOES change) when I test the dialogue it always skips the lines that have Commands in them.

Even if the command works perfectly, the dialogue line are skipped to the next one that as no Sequence command in them.


(p.s. - Nice art style! )
Thanks! I appreciate it C:

This is what I have so far:

gdbaradit
Posts: 14
Joined: Mon Sep 09, 2019 1:25 pm

Re: Can I play the "Idle" and "Talking" animation using Dialogue System Events Component?

Post by gdbaradit »

Continuation...


Heres a video of said issue:



:D
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can I play the "Idle" and "Talking" animation using Dialogue System Events Component?

Post by Tony Li »

Hi,

Set the Sequence to:

Code: Select all

AnimatorBool(talking, true);
AnimatorBool(talking, false)@{{end}}
Each line lasts for the duration of its Sequence.

If the Sequence field is blank, it uses the Dialogue Manager's Default Sequence, which is initially:

Code: Select all

Delay({{end}})
This makes the sequence delay for a duration based on the length of the text.

The AnimatorBool() sequencer command takes no time to run. When your Sequence is only this:

Code: Select all

AnimatorBool(talking, true)
then it runs and finishes immediately, so it proceeds to the next line immediately.

By adding AnimatorBool(talking, false)@{{end}}, the Sequence waits for a duration based on the text length. Then it sets the talking parameter false.
gdbaradit
Posts: 14
Joined: Mon Sep 09, 2019 1:25 pm

Re: Can I play the "Idle" and "Talking" animation using Dialogue System Events Component?

Post by gdbaradit »

Got it !!! And solved!! I thought the system skipped the wrongly written sequences and I had some syntax error.

Thanks for your time, Toni.

I'll try to keep the posting to the minimum to not abuse your time.

THANKS!
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can I play the "Idle" and "Talking" animation using Dialogue System Events Component?

Post by Tony Li »

I'm here to help, so feel free to post whenever you have a question!
mindjar
Posts: 12
Joined: Tue Aug 06, 2019 11:22 am

Re: Can I play the "Idle" and "Talking" animation using Dialogue System Events Component?

Post by mindjar »

Does above code works even with Fast Forward Script? I've noticed that when I skip dialogues the animator parameter continues to play. I don't know if it's something on my end or it's a bug.
Post Reply