Monday, July 18, 2011

Unity FPS Shooter Game tutorial #5

Picking up a weapon

var gotShotgun : boolean = false;
 var gunPickupSound : AudioClip;
 function Start ()
//playerWeapons is the players selectable weapons 
playerWeapons = this.GetComponent("PlayerWeapons");
 }
 function OnTriggerStay ()
{
 if (Input.GetButtonDown("Pickup"))
gotShotgun = true; 
Destroy(gameObject);
 //Play Gun Pickup Sound
 if (gunPickupSound) 
AudioSource.PlayClipAtPoint(gunPickupSound, transform.position); 
print("You Picked Up The Double Barel Shotgun"); 
}
 }

No comments:

Post a Comment