【发布时间】:2014-06-21 00:23:34
【问题描述】:
我正在尝试在更新函数中调用射击动画,然后等待 0.5 秒,然后再生成激光射击。下面的代码对我不起作用。我该怎么做才能达到预期的效果?
void Update()
{
if (Input.GetMouseButtonDown (0))
{
animator.SetTrigger("Shoot"); // Start animation
WaitAndShoot();
}
}
IEnumerator WaitAndShoot()
{
yield return new WaitForSeconds(0.5f);
Instantiate (shot, shotSpawn.transform.position,shotSpawn.transform.rotation);
}
【问题讨论】:
-
我发现unitygeek.com/coroutines-in-unity3d 对理解 Unity3d 中的协程很有帮助