Game Development Reference
In-Depth Information
5. Drag your new zombie ragdoll object from the Hierarchy view to the new prefab
icon in the Project view. This will turn the zombie ragdoll into a prefab and make the
prefab icon turn blue. The zombie ragdoll's entry in the Hierarchy list will also turn
blue, signaling that it is part of a prefab.
6. Now that you have a prefab zombie ragdoll, return to your game scene after saving the
RagdollGenerator
scene. Add the prefab ragdoll object to the Dead Replacement vari-
able in the Professor Zombie's Body Destroy component panel in the Inspector view.
7. Create another new prefab in the Project window, naming this one
ProfessorZombie
.
Add the finished zombie to the prefab. Save your scene and project.
Now that the zombie is finished and saved as a prefab, you will arm the player so that
he or she can shoot the zombie. You will also add scripts that will make the player killable
by the zombie enemy.
Turning the First Person Controller into an FPS Hero
While the First Person Controller is an excellent prefab, it does not have the necessary
elements to be a full game character. The basic elements of turning this prefab into a play-
able first-person shooter (FPS) hero include making the player killable, making the game
reload if the player dies, and giving the player a gun to shoot the zombie with. After this is
completed, the player can actively fight the zombie character you created.
Making the Player Killable
First, you will make the player killable so the
ZombieStationary.js
script's damage mes-
sages are received by something.
1. If it is not already open, open your Unity file and add a new JavaScript file called
FPSPlayer.js
to the
Scripts
folder in the Project view.
2. Open this script and type the following code into the window. This
Awake
function
calls the function
StepSounds
, which you'll add later in the script, and defines the pri-
vate variable
healthGUIWidth
as the numerical width measurement of the GUI Texture
object stored in the
healthGUI
variable. This variable stores a new type of game object
called a GUI Texture, which you will add to the scene after working with this script.
var maximumHitPoints = 100.0;
var hitPoints = 100.0;
var healthGUI : GUITexture;
var walkSounds : AudioClip[];
var painLittle : AudioClip;
var painBig : AudioClip;
var die : AudioClip;
var audioStepLength = 0.3;
private var healthGUIWidth = 0.0;
private var gotHitTimer = -1.0;
Search WWH ::
Custom Search