【发布时间】:2018-08-31 01:22:38
【问题描述】:
我做了一个坦克,点击鼠标就可以发射球。
我的 C# 脚本:
GameObject prefab;
// Use this for initialization
void Start () {
prefab = Resources.Load("projectile") as GameObject;
}
// Update is called once per frame
void Update() {
if (Input.GetMouseButtonDown(0))
{
GameObject projectile = Instantiate(prefab) as GameObject;
projectile.transform.position = transform.position + Camera.main.transform.forward * 2;
Rigidbody rb = projectile.GetComponent<Rigidbody>();
rb.velocity = Camera.main.transform.forward * 40;
}
}
在这个脚本中,我正在拍摄一个名为 projectile 的网格。但我想拍摄粒子球而不是网格。我已经尝试将脚本上的particle 更改为Orbparticle,但没有生成任何对象。我做错了什么?
【问题讨论】: