Game Development Reference
In-Depth Information
Fig 4.13 A cube used as a
platform.
Step 10. Create a new JavaScript file called releaseDuck.js . Add the
code in Listing 4.21 .
Listing 4.21 Script to Make a Game Object Appear after
Collision with Another
var duckObj: GameObject;
function OnTriggerEnter(collision: Collider)
{
print(collision.gameObject.name);
if(collision.gameObject.name == "chassis collider")
{
var newDuck = Instantiate(duckObj, this.transform.
position, Quaternion.identity);
//start duck up above the ground
newDuck.transform.position.y = 10;
}
}
Search Nedrilad ::




Custom Search