The best way to single animations
The best way to single animations
Hi Tony and everyone! My player has several animations (surprise, anger, other emotions) and I want to call them in the dialogue. But I still can't figure out how to do it better. AnimatorPlay? AnimatorTrigger? Or for example use some third party script (for example I have Playmaker in my project)? For example when I used AnimatorInt in a sequence everything worked, but if I specify AnimatorInt in the next line of the dialog (to return the standard emotion), it stops working. I don't understand, does the dialog system preload the next sequence? Anyway, I need some advice on how to better implement such single animations. For example, the mouth animation in my project is implemented through default player sequence - AnimatorPlay. And mouth animations works great, but when it comes to single animations (when i need return players face to default animation) - works intermittently. Thanks!
Re: The best way to single animations
Hi,
I generally use AnimatorPlayWait() and AnimatorPlay(), although it depends on how your animator controller is set up. If your animator controller has transition arrows that lead from one state to another based on animator parameter values, you might need to use sequencer commands such as AnimatorTrigger() and AnimatorBool() that set those animator parameters.
Your mouth animations are working, but it's a good example to start from so I'll describe how I usually set it up. I'll add two animation states to my animator controller: Idle (mouth closed) and Talking (mouth moving). Then I'll use this sequencer command to make the mouth move while the typewriter is typing:
The typewriter effect always sends the sequencer message "Typed". The second AnimatorPlay() waits for this message. The "required" keyword is essential. If the player skips ahead before AnimatorPlay() receives the message, the required keyword guarantees that the command runs anyway.
Here's an example that plays a Dance animation state and then returns to Idle when it's done:
The first command plays the Dance state, waits until it's done, and then sends the message "Done", which is an arbitrary string I chose.
The second command waits for the message "Done" and then plays Idle. If the player skips ahead, the required keyword guarantees that it still goes to Idle.
When I'm using continue buttons, I'll often use this trick:
The first command puts the animator in the Talking state. The second command waits for the message "Continued". This is another arbitrary string I chose. Nothing in the Dialogue System actually sends this message. This means the command will wait forever. However, the player can skip ahead by clicking the continue button, at which point the required keyword guarantees that the command will run.
I generally use AnimatorPlayWait() and AnimatorPlay(), although it depends on how your animator controller is set up. If your animator controller has transition arrows that lead from one state to another based on animator parameter values, you might need to use sequencer commands such as AnimatorTrigger() and AnimatorBool() that set those animator parameters.
Your mouth animations are working, but it's a good example to start from so I'll describe how I usually set it up. I'll add two animation states to my animator controller: Idle (mouth closed) and Talking (mouth moving). Then I'll use this sequencer command to make the mouth move while the typewriter is typing:
Code: Select all
AnimatorPlay(Talking);
required AnimatorPlay(Idle)@Message(Typed)
Here's an example that plays a Dance animation state and then returns to Idle when it's done:
Code: Select all
AnimatorPlayWait(Dance)->Message(Done);
required AnimatorPlay(Idle)@Message(Done)
The second command waits for the message "Done" and then plays Idle. If the player skips ahead, the required keyword guarantees that it still goes to Idle.
When I'm using continue buttons, I'll often use this trick:
Code: Select all
AnimatorPlay(Talking);
required AnimatorPlay(Idle)@Message(Continued)
Re: The best way to single animations
Oh, thank you so much! Another question: is using the Dialogue System Events component the right way to set the animation? or is it better use sequencer? I did as you said, but the mouth animation during barking doesn't work, which means I need to use dialogue system events.
I'm just trying to find a more elegant and optimized .solution for this.
I'm just trying to find a more elegant and optimized .solution for this.
Re: The best way to single animations
You can use sequences for barks, too. See the enemies in DemoScene2 for an example. Their bark conversation uses Audio() sequencer commands.