我想发射子弹,点击鼠标生成一颗,点一下生成一颗,而且每生成一颗,程序就会自动计数,结果变成点一下,所有的子弹都一分二位,但是子弹数只加1
#pragma strict
function Start () {
}
var newobject:Transform;
var shedanshu:int=0;
function Update () {
if(Input.GetButtonDown("Fire1")){
var n:Transform=Instantiate(newobject,transform.position,transform.rotation);
var fwd:Vector3=transform.TransformDirection(Vector3.forward);
n.rigidbody.AddForce(fwd*2800);
shedanshu++;
gameObject.Find("gt").GetComponent(GUIText).text="射弹数"+shedanshu;
}
}
java语言
catspeake