Download Downloads - All IT eBooks
Transcript
274
CHAPTER 10: Putting the Pieces Together and Building Your Game
Figure 10-4. Remove the Ball and Ball User Control scripts from the Land Mine game object in the Inspector
Finally, you will need a script that tells the Land Mine to explode if the player character comes in
contact with it, destroying the land mine and killing the player character. In the Project panel open
Assets ä Script, then create a new script named LandMineExplosion and open it in MonoDevelop.
Edit the code as follows:
#pragma strict
public var victim : GameObject;
public var explosionPrefab : GameObject;
function Start () {
victim = GameObject.FindWithTag("Player");
}
function OnTriggerEnter (collider : Collider) {
if (collider.gameObject == victim) {
Explosion();
}
}
function Explosion () {
victim.GetComponent(GoRagdoll).GotoRagdoll();
Instantiate (explosionPrefab, transform.position, Quaternion.identity);
Destroy(gameObject);
}
This code breaks down as follows:
(1)
1.
private var victim : GameObject;
Declare a private GameObject type reference variable named victim for the
player character reference.
(2)
public var explosionPrefab : GameObject;
Related documents
CameraTool: Pipeline Optimization for Camera Setup in the Unity
Gizmoball 3D: Final Design Document
Adventure Creator manual
Report Appendices
- ePrints
there
CMSC 425 Lecture Notes - University of Maryland at College Park
humanos virtuais em ambientes de treino de competências sociais
ICE CREATURE CONTROL
MSP430 Assembly Language Tools v 3.1 User's Guide (Rev. C
11_DIY_0415_FR_mail
TMS320C55x Assembly Language Tools User's Guide (Rev. H)