Game Development Reference
In-Depth Information
function Update () {
//this bullet move down
transform.Translate(Vector3(0,-2,0));
//destroy bullet below this height
if(transform.position.y<-30)
{
Destroy(gameObject);
}
}
function OnTriggerEnter(other:Collider)
{
//check collision with player's ship
if(other.gameObject.tag=="PlayerShip")
{
Destroy(gameObject);
Destroy(other.gameObject);
//we will improve this later
Debug.Log("Game Over");
}
//check collisions with barriers
if(other.gameObject.tag=="BarrierBrick"){
Destroy(gameObject);
Destroy(other.gameObject);
}
}
4. You may notice that the collision between the alien bullet and the player's
ship is dependent on the player's ship being tagged as "PlayerShip" . We
thus need to add this tag into the Tag Manager panel and then add the tag
to the PLShip prefab. You shouldn't have problems doing this by now.
Search WWH ::




Custom Search