Part 5 of 5: Creating smart enemy characters using Unity3D - Be attacked and die beautifully
Welcome to Part 5 in our series of developing a smart enemy character using Unity3D.
Here are links to the full series.
1) Patrol their region and have some fun
2) Be self-aware and determine proximity to main player
3) Run to main player
4) Attack main player
5) Manage health & die beautifully
In this blog post we will cover how to be attacked by our player and die beautifully.
Download a simple character with animations built-in from the Asset store.
Here's a nice animated person model you can download quickly from the Asset Store:
https://www.assetstore.unity3d.com/#/content/3012
Import it into your project.
This model comes with various animations:
> Die
> Walk
> Idle, etc.
Now, drag this model into your scene.
Next you can create a simple script to test the various animations.
enemyscript.js
#pragma strict function Update () { animation.Play("death"); }
This will simply run the death animation in a loop.
Yes this is pretty simple death script and we can make it exciting by adding a sound clip and some particles.
Let's start by looking at some quick ways to make our participant bleed.
Click here to download a simple unitypackage, it has some blood material and particles.
Next import BloodyPreFab into your project. This will give you a Blood PreFab that you can use for the character animation.
Now position the blood particles on top of the character, perhaps on the chest.
That's all the personality we need (for now :)
Instantiate the bloody PreFab just when you need it and pair it with the "Die" animation and your character will "Die" just as it bleeds.
Let's try this by instantiating the Blood PreFab in Update.
Hope you enjoyed the experience of building your enemy character step-by-step.
We will cover more advanced enemy character features in the future. Leave us a comment and let us know what else you would like to see.
















