Unity敌人刷新

来源:互联网 发布:mac see sheer真人试色 编辑:程序博客网 时间:2024/04/28 12:50
    float timer = 0;    float timer2 = 0;    //产生敌人的速率    public float rate;    //敌人的预制体    public GameObject enemeyPrefab;    //每一波的时间    public float timesofEachWave = 30;    //每一波的已经产生的数量    public int count;    // Use this for initialization    void Start () {    }       // Update is called once per frame    void Update () {        timer2 += Time.deltaTime;        if (timer2 < timesofEachWave && count!=10)        {            timer += Time.deltaTime;            if (timer > rate)            {                Instantiate(enemeyPrefab, Vector3.zero, Quaternion.identity);                count++;                timer -= rate;            }        }        if (timer2>timesofEachWave)        {            timer2 -= timesofEachWave;            count = 0;        }    }
原创粉丝点击