- Home /
Make AI enemies react to bullet hits (Solved)
I'm wondering if there is an effective way to have my "Alien Zombies" emit a cry of pain each time they get shot? I'm thinking I would put this somewhere in the "Character Damage" script but not sure what a good way to code it would be?
I'm guessing it would go in the function ApplyDamage somewhere?
Has anyone done something like this?
EDIT I figured it out. I just added:
function ApplyDamage (damage : float) {
if (hitPoints < 100){
yield WaitForSeconds(0.5);
// Play Alien Pain Sound
audio.PlayOneShot (alienPainSound);
}
That little extra into the apply damage function so he scream when he gets hit. I don't know if if would work over an extended period. longer than how I'm using it as my Alien Zombies only have 100 hit points and the shotgun does 50 damage each blast.
But it works in this case as the secound shot kills them and there is a different "Alien Squeel" sound for when they die.
Late Edit I added a wait for secounds in there just so there is a half a second delay on the "Alien Pain Sound" because sometimes over the shotgun blast it was kind of hard to hear so this way there is a little delay for the shotgun sound to finish and the "Alien Pain Sound" to begin... works much better now ;)
Your answer
Follow this Question
Related Questions
AI aim and shoot projectile at Player 1 Answer
Wandering AI Monster 2 Answers
how to make an enemy Ai blow up when you shoot it? 2 Answers
enemy shoot AI precision 1 Answer
AI problems ( enemy doesn't shoot ) 2 Answers