Game Development Reference
In-Depth Information
function Update () {
//move bullet up once created
transform.Translate(Vector3(0,2,0));
//Y=100 defines upper screen limit
if(transform.position.y>100)
{
//destroy bullet as it goes
outside the upper
//screen limit
Destroy(gameObject);
//once the bullet is destroyed,
allow the player
//to shoot again
moveShip.canShoot=true;
}
}
//this function checks for collisions
function OnTriggerEnter(other:Collider)
{
//if bullets collides with aliens,
destroy both
if(other.gameObject.tag=="Enemies"){
Destroy(gameObject);
Destroy(other.gameObject);
//once the bullet is destroyed,
allow the player
//to shoot again
ControlShip.canShoot=true;
}
//if bullet collides with barriers,
destroy it and a
//piece of the barrier
if(other.gameObject.tag=="BarrierBrick"){
Search WWH ::




Custom Search