Trigger animations?

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Trigger animations?

Post by Tony Li »

SuperSparkplug wrote:
Hi there,

How to I trigger animation clips or variables that trigger animation clips through the dialogue system? I want to make it so I can activate specific animations on certain responses or dialogue sequences.
Hi,

Use a sequencer command in your dialogue entry’s Sequence field. If you’re using Legacy Animation, use the Animation() command. If you’re using a Mecanim Animator, use AnimatorPlay() to crossfade to a state, AnimatorTrigger() to set a trigger parameter, or one of the other Animator-related commands as fits your needs.

For example, say you want a Mecanim-controlled character to play the “Curtsy” state. Make your dialogue entry look something like this:
  • Dialogue Text: “Pleasure to meet you.”
  • Sequence: AnimatorPlayWait(Curtsy)
bohnstudios
Posts: 68
Joined: Sun Aug 16, 2015 3:01 am
Location: St. Louis, MO
Contact:

Re: Trigger animations?

Post by bohnstudios »

Hi Tony, Would it be possible for you to make a demo that uses mecanim to call animations? The legacy animation sequencer command Animation() works like a charm. Overall, Dialogue System is working great with my game btw.

The closest example I could find was the third-party salsa demo you made. Is there another one that uses mecanim that I missed? Your main demos seem to be all legacy... I think my main issue is setting up the animator controller correctly. In the Salsa demo, the mecanim state machine associated with the demo Ethan NPC only contains the idle state. In the dialogue tree when the AnimatorPlay() sequencer command calls another animation, Ethan remains in idle.

I could be missing something really basic, I'm not sure. Do I need a separate script to handle my states or is there a recommended way to make DS interract with the animator controller?

I am still learning Mecanim. I've been pouring through tutorials. A simple example that contains a controller with a few more states or updating the Salsa third-party demo would probably put me on the right track rather quickly.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trigger animations?

Post by Tony Li »

Hi,

Here's a simple example: AnimatorExample_2015-11-09.unitypackage

It imports into a folder named Animator Test. The NPC, Mecanim Trooper, has two states: Idle and Kick. When you talk to him, he'll use AnimatorPlayWait to switch to the Kick state, which has an automatic transition back to Idle.

If you'd like a more complex example, or if you have any questions about using the AnimatorXXX() commands, just let me know!
bohnstudios
Posts: 68
Joined: Sun Aug 16, 2015 3:01 am
Location: St. Louis, MO
Contact:

Re: Trigger animations?

Post by bohnstudios »

This should keep me busy for a while. I'm using Mixamo characters and animations with Salsa in my project file so it will take me a sec to put it into what I've got. I'll let you know how it works out. Seeing how you set the controller for automated transistions was extremely helpful in pointing me in the right direction. Thank you!
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trigger animations?

Post by Tony Li »

I use Mixamo and SALSA, too, so please ask if any questions pop up.
bohnstudios
Posts: 68
Joined: Sun Aug 16, 2015 3:01 am
Location: St. Louis, MO
Contact:

Re: Trigger animations?

Post by bohnstudios »

Well that makes me feel like I made a good decision to use them :) So..... I messed up my Salsa+ARPG+Mixamo+DialogueSystem prototype....had everything working perfectly minus the mecanim animation sequencer example you just showed me...basically I haven't got to really try that feature out yet per your latest example. I'm going to try and redo that feature prototype/template tomorrow step-by-step...and make my notes better for whenever I need to duplicate the process.

I did notice that in your example that the recon soldier had all of the animations under a single prefab whereas the mixamo animations are skeletal fbx's in a model@fbx format. Not sure if that would make a difference. In a stand-alone state machine it doesn't seem to matter, but we'll see.

I need to improve my step-by-step notes so I don't get lost when I need to duplicate the process for the combo I have. It's going to be worth it though. I've found salsa to be really solid...been getting really accurate lip sync as long as I compress/boost the raw audio in my DAW first.

I'll probably spend most of the day on it tomorrow. I need to do it just pound some of these things into my head so I don't forget. One can't expect to get things AAA level without a little elbow grease eh?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trigger animations?

Post by Tony Li »

BTW, my setup sounds similar to yours -- Mixamo animations in separate model@fbx format. They're even built for a different rig than my character models, which I built in Fuse. Gotta love Mecanim's retargeting! The ReconTroop model with embedded animations was just a convenient way to set up an example scene.
bohnstudios
Posts: 68
Joined: Sun Aug 16, 2015 3:01 am
Location: St. Louis, MO
Contact:

Re: Trigger animations?

Post by bohnstudios »

Yeah retargeting is really helpful. Even making separate walking animations for every character would be so time consuming.

I'm a lot closer than I was. I was able to get it somewhat working with the AnimatorPlay command, but it's really jittery and something is not right. This might be mixamo related and I think it might have something to do with the scale of the my mixamo fbx. When I drag it into my scene the humanoid model is really small. Have you run into any issues regarding scale with fuse/mizamo characters?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trigger animations?

Post by Tony Li »

I don't recall any issues, but it's a while since I set up the characters. I usually scale the model when I import it (on the Model tab). This way I can leave the GameObject in the scene at (1,1,1) scale.

The only thing special I do with Mixamo animations is set them to Bake Into Pose and Original all around.
bohnstudios
Posts: 68
Joined: Sun Aug 16, 2015 3:01 am
Location: St. Louis, MO
Contact:

Re: Trigger animations?

Post by bohnstudios »

Thanks!
Post Reply