//前提是创建子弹预制体,把预制体拉进BulletPrefab里面
using UnityEngine;
using System.Collections;
public class game : MonoBehaviour {
public GameObject BulletPrefab;
// Update is called once per frame
void Update () {
//创建子弹
GameObject bullet = Instantiate(BulletPrefab, Vector3.zero, Quaternion.identity) as GameObject;
//1秒销毁子弹
Destroy(bullet,1);
}
}
原文:http://www.cnblogs.com/lzl0823/p/6294811.html