【发布时间】:2016-12-06 19:41:13
【问题描述】:
我正在创建一个自上而下的 2D 游戏。下面是让我的播放器实例化子弹的代码:
public GameObject bullet;
void Update ()
{
if (Input.GetButton("Fire1") && Time.time > nextFire)
{
nextFire = Time.time + fireRate;
Instantiate(bullet, transform.position, transform.rotation);
}
}
这是附加到子弹上的脚本,以使其移动:
void Update ()
{
transform.Translate(transform.forward * Time.deltaTime * speed);
}
子弹似乎只在其 Z 轴上移动,而在 2D 游戏中它看起来好像是静止不动的。如何解决?
【问题讨论】:
-
除了transform.forward,你有没有尝试过其他方向?
-
那么用
transform.right沿局部x 轴移动怎么样?
标签: unity3d rotation projectile