So I said to my kid, I bet I can put a Dragon into the game…
So how do we do this thing?
First, we need a Controller for the Dragon and we need to get the Dragon’s Avatar. In this case, the guys and gals at Infinity PBR provided a controller hooked up on the model, so I just stole the Avatar off of that one. The Controller is duplicated from the Zombie Controller.
In the graphic below you can see the various animations from the Dragon PBR character. All you need to do (AFTER duplicating the Zombie Animator Controller) is replace each of the animations with the corresponding animation from the Dragon.
Bug in the Dragon Attack
So the next step is to get that Dragon to attack. I’ve got it working… sort of. She doesn’t seem to want to stop on a dime and she attacks longer than she should.
Well, before we get too far into it, here’s a video about creating a new base prefab for my Enemy Game Object and then deriving Variants from it:
Time for an Architecture Review on the Attack AI. Let’s see what’s in there that might need fixing.
- Change the Attack Trigger to a boolean flag.
- Figure out why the Dragon has a couple of extra running cycles with no actual movement.
Changing the Attack Trigger
So here are the new Animator settings for one the Attack exit transitions. Note the addition of the Walking parameter. We need to tell Attack which State it should transition toward. The transition to Idle will be the same except the Walking flag will check for a False condition.
I switched up the Attack method of the Zombie Animator to work with a Boolean flag.
At least one part of the solution is to remove the stopping distance parameter from Follow Target.
OMG GUYS! GUYS! The bug was in the Aggression component! There are TWO ways that Follow Target gets set:
- A Target is found by the Search for Targets component.
- A Target is found because we got slapped and the Aggression component is upset.
So the bug was that the Dragon wasn’t entering the Attack component at all. It did not have a target. The overrun was caused because a Target wasn’t being sent to Attack until the Aggression component reduced Hate to 0.
Animator Override Controllers
I totally forgot about these gems! May the Great TechnoWizard look kindly upon the designers of this Feature!
To use an Animator Override Controller you drag in the Controller you want to override and then drag in the animations you want to replace.
Not replacing an animation will use the original animation, so keep that in mind.