- Home /
Zombie attack script help
Hello. I have everything ready for my A.I it has pathfinding that works animations follows me everything but attack.
could someone make/point me in the right direction of a script?
I want it so when the zombie is close he attacks/play animation attack and then take damage off me
Any tutorials or advise would really be appreciated
are you familiar with collider and trigger ?
is so just add a trigger around your hero (perhaps a sphere) of whatever size you want (say 3m).
when the trigger fires, run the animation, etc.
Answer by justinl · Sep 17, 2012 at 08:41 AM
I would draw a raycast line between the zombie and the player. If the zombie has clear sight of the player AND the line is less than say... 2 units, then have the AI do a melee attack (google unity melee tutorial to find out the specifics of implementing this, one method to get the distance between 2 objects is found here: http://forum.unity3d.com/threads/37918-Distance-between-two-objects). This melee attack should check to see what type of object it has hit. If it has hit the player object, you can use SendMessageUpwards() to send a message to the player object to say "apply damage" and also how much damage to apply.
Here is a video tutorial of building a raycast gun. It's not specifically what you want, but it tells you the details of how to give damage to another object. You may need to watch part 011, 012, and 013. I've forgotten where the damage specific stuff is.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
ZOMBIE AI SCRIPT 1 Answer
Ai Zombie Melee Attack script. 5 Answers
Controlling AI Movement 0 Answers
Script Attack zombie 1 Answer