using UnityEngine;
using System.Collections;
public class Spawner : MonoBehaviour {
public float spawnTime =5f;//每个敌人产生的时间间隔
public float spawnDelay = 3f;//敌人产生开始前的时间。
public GameObject[] enemies;//敌人预设的数组
// Use this for initialization
void Start () {
//在延迟一段时间后反复调用Spawn函数
InvokeRepeating("Spawn", spawnDelay, spawnTime);
}
void Spawn(){
//实例化一个随机敌人
int enemyIndex = Random.Range (0, enemies.Length);
Instantiate (enemies [enemyIndex], transform.position, transform.rotation);
//播放子物体中所有粒子特效
foreach(ParticleSystem p in GetComponentsInChildren<ParticleSystem>())
{
p.Play();
}
}
}
2D 敌人生成 特效播放
最新推荐文章于 2021-04-25 18:42:31 发布
4831

被折叠的 条评论
为什么被折叠?



