Zombies and text input
In addition to the FSM for zombie behaviors, like Idle, Chase, Attack, and Death, zombies respond to player input. Specifically, the player may attack by typing letters on the keyboard, matching the complete word above the zombie's head:
Attacking zombie with typed text input
To achieve this, we must firstly display a word above the zombie's head, then keep track of the word being typed, and finally determine whether a match has been made. We already have some code to achieve much of this, but we should now link it specifically to the zombie character. Let's start by creating a text object that hovers above the zombie's head. Select the zombie NPC and expand its hierarchy in the Hierarchy panel. Select the Armature object and locate the h ead bone. This represents an empty game object used to move the character head during animation. Any object attached to the head bone therefore moves with the character head:
Selecting the character head bone
Now right-click the selected...