Game Development Reference
In-Depth Information
This function evaluates the value of the Boolean variable Cake . If the value of Cake is
true, then the program prints one message; otherwise it prints a different message.
Of course, there are other conditional statements that appear sporadically, but these
are enough to get you through the next few pages. In the next section, you will use scripts
to make the zombie chase the player and implement some other functions to turn your
model into an interactive game character.
Adding Interactivity to the Zombie
Going from simple if statements to scripting behaviors is a tall order. However, the
tutorials available on the Unity website's resource section, located at http://unity3d.com/
support/resources /, contain several useful scripts that form the foundation for many
of the scripts in this chapter. By using these scripts and knowing that they are based
on other resources, you can explore the examples in this topic and on the Unity site to
improve your understanding of scripting concepts.
In this section, you will utilize a script created from parts of the Unity first-person shooter
online tutorial and the third-person platformer tutorial to make the zombie chase the player.
Making the Zombie Chase the Player
First, you will set up the zombie by adding its mesh to the scene. You will also give it
some colliders to be used by other scripts.
1. Open your Unity scene or open ZombieGameStart.unity from the Assets b Scenes
folder of the Unity project directory in the Chapter 10 online resources.
2. In the project view, find ProfessorZombie.fbx and place the creature in front of your
First Person Controller in Unity, as shown in FigureĀ 10.7.
3. With the zombie object selected, go to the Components menu at the top of the Unity
interface and add a Physics b Character Controller component to the zombie. This
will add a Character Controller to the zombie mesh, a special type of collision object
for characters.
FigureĀ 10.7
Adding the
imported zombie in
front of the player
Search WWH ::




Custom Search