unity 使用代碼創建子彈


                                                                                                                   //前提是創建子彈預制體,把預制體拉進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);

}
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM