The snippet below makes the zombie decide what to do when the player provokes it.
The zombie has a nav mesh agent attached to it so it can move around in the world. Here I am using the agent to decide if the zombie continues to chase the player (if not already attacking) or attack the player (if it caught up to the player). Line 75 is what makes the zombie lock on to the player.
In another method, the value of currentWeapon changes when the player presses 1, 2, or 3. After that, in this method, I iterate through all the weapon's transforms, using weaponIndex as the starting point. If it matches what currentWeapon is, then I set that as the weapon the player is holding. otherwise the weapon is turned off.
Once colliding with the player, the pickup will search them
for the Ammo component (representing the ammo slot). That
component has a method to increase the amount of ammo.
The FlashLightSystem is attached to my flashlight object. I
placed the flashlight under the MainCamera so it would light
the way the player sees. So this pickup needs to search the
Player object's children for the flashlight system to be able
to replenish the flashlight.
I have a method for the "Move", "Attack" and "Die" states. The "Attack" method is really simple. All I need to do is get the Animator and set a bool to true so the zombie gets the "ok" to attack. They might be zombies, but they are still nice people. They'll only attack you if you allow them to.