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?

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.