unity3d报错显示MissingReferenceException:射击变量Bullet不再存在。 您可能需要在检查器中重新分配“射击”脚本的Bullet变量

img

public float Speed = 10f;
public GameObject Bullet;
public GameObject Fpoint;
//public float nextshoot;
//public float jiange;


// Use this for initialization
void Start () {
    //jiange = 2;

}

// Update is called once per frame
void Update () {
    if (Input.GetKeyDown(KeyCode.M)){

        //nextshoot = Time.time + jiange;
        //i++;

        //初始化炮弹实例
        GameObject zidan = (GameObject) Instantiate (Bullet, Fpoint.transform.position, Fpoint.transform.rotation);
        //zidan.GetComponent ().AddRelativeForce (Fpoint.transform.TransformDirection(Vector3.forward * Speed));
        //发射炮弹,给炮弹的刚体组件一个速度和方向
        zidan.GetComponent().velocity = Fpoint.transform.up * Speed;

        /Destroy (zidan,2);

        //GameObject.Find ("Text").GetComponent<Text> ().text = "score:" + i;
    }
}

}