Game Development Reference
In-Depth Information
GameObject.Find(“ScoreDynamic”).SendMessageUpwards(“NewScore”, r
PointValue, SendMessageOptions.DontRequireReceiver);
Kill();
}
}
function Kill () {
if (DeadZombie)
Destroy(gameObject);
if (deadReplacement) {
var dead : Transform = Instantiate(deadReplacement, r
transform.position, transform.rotation);
}
}
Figure 10.11
BOOM headshot!
2. Note the section of the code that finds the game object called
ScoreDynamic
. This will
be added later in the chapter to count and display a score. However, because this
object and the scripts it uses do not exist yet, comment out these lines by typing
//
before each line or by typing
/*
at the beginning of the section and
*/
at the end.
3. Place this new script in the Inspector view of the
ProfessorZombie
object.
4. Save your scene and project.
You can specify a transform object in the
deadReplacement
variable. Replacing a destroyed
object with either a damaged version of itself or, in the case of characters, a ragdoll adds an
element of realism to your game.
Before you add anything else to the scene, you will quickly create a ragdoll object to
act as a dead replacement for the zombie.
Search WWH ::
Custom Search