|
var FirePoint : Transform;
var Bullet : Rigidbody;
var BulletCnt : int = 30;
var BulletSpeed=100;
var myStyle:GUIStyle;
private var CurrBullet : int;
function Start(){
CurrBullet=BulletCnt;
}
function Update () {
if (FirePoint==null||Bullet==null){
return;
}
if(Input.GetKeyDown(KeyCode.Space)){
if(CurrBullet>0){
var clone : Rigidbody;
clone=Instantiate(Bullet,FirePoint.transform.position,FirePoint.transform.rotation);
clone.velocity=transform.TransformDirection(Vector3.forward*BulletSpeed);
CurrBullet-=1;
}
}
}
function OnGUI()
{
GUI.Label(Rect(30,30,60,30),"Bullet:"+CurrBullet,myStyle);
}
|
评分
-
查看全部评分
|