- Home /
zombie attack script
i am almost done with my zombie game i just need to add the zombie attack script, and fix the gun. i made the attack animation but i still need to put in an attack script that will cause the zombie to attack the player when close enough and play the attack animation at the same time(duh). i have put in the box colliders that i need but i cant figure out how to write the script. can someone help me write it out?
Answer by rutter · Apr 08, 2012 at 03:04 AM
You could potentially use `OnCollisionEnter()`, `OnTriggerEnter()`, along with their related stay/exit hooks, or other related functions to manage a lot of this behavior. Check out Unity's physics and collision manual.
As an alternative, you could use Update()
to check distance between player and zombie, by passing their transform positions to `Vector3.Distance()`.
Was there some specific part of this process that you're having trouble with? It's hard to answer such a general question. A lot of opening questions can be answered by carefully reading the introductory chapters of Unity's manual.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
how to make an AI damage a third person controller ? 1 Answer
How can i check if my Player was in the attack animation of my Enemy(2D) 1 Answer
How can I make my Axe in unity do damage to my Zombies 6 Answers
How do I get my enemy to attack? 0 Answers