Game Development Reference
In-Depth Information
The last section creates graphics for the zombie's attack and punch radii that appear in
the Unity Scene view. Visualizing these elements can help a designer make decisions on
how far the influence of certain scripts should be (Figure 10.9).
Figure 10.9
The zombie with
attack and punch
radii visible
function OnDrawGizmosSelected ()
{
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere (transform.TransformPoint(punchPosition),
punchRadius);
Gizmos.color = Color.red;
Gizmos.DrawWireSphere (transform.position, attackDistance);
}
@script RequireComponent(AudioSource)
Now you'll add this script to the ProfessorZombie object:
1. Select the zombie, and then LMB-drag the script from its place in the Project view
to the bottom of the zombie's Inspector window. The cursor should show a plus sign
when you can add it. After it is placed, ensure that the variable settings are the same
as those shown in Figure 10.10.
2. Select the First Person Controller that you have designated as the Player object, and
then go to the top of its Inspector view settings. There is a pull-down list above the
object's transform settings marked Tags. Open the Tags list and select Player from
the options.
Search WWH ::




Custom Search