Game Development Reference
In-Depth Information
FIG 6.15 Adding a box collider to
a particle system.
Step 46. Create a new tag called fire and set this to the tag for Fire1.
Step 47. Open pickup.js and add an OnTriggerStay() function as shown
in Listing 6.17 to continually reduce the player's health while standing in
the fire.
Listing 6.17 Using a Trigger to Determine When a Game Object
Is Inside Another's Collider
. . .
function Start()
{
//first held object
currentObj = GameObject.Find("wrench");
}
function OnTriggerStay (other : Collider)
{
if(other.gameObject.tag == "fire")
{
Camera.main.GetComponent("gui").health =
Camera.main.GetComponent("gui").health
- 1;
}
}
function OnControllerColliderHit (hit : ControllerColliderHit)
{
. . .
Search Nedrilad ::




Custom Search