- 最后登录
- 2018-6-29
- 注册时间
- 2011-7-1
- 阅读权限
- 20
- 积分
- 359
- 纳金币
- 335582
- 精华
- 0
|
var FirePoint:Transform;
var Bullet:Rigidbody;
var BulletCnt:int=30;
var BulletSpeed=30;
var myStyle:GUIStyle;
private var currBullet:int=30;
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);
}
|
|