如何在旋转发生之前设置延迟?

时间:2015-08-27 18:49:05

标签: c# unity3d

如何在轮换发生前设置延迟?我试过StartCoroutine,=

1 个答案:

答案 0 :(得分:1)

计时器怎么样?

Timer timer = new Timer();
timer.Interval = 500; // Milliseconds
timer.AutoReset = false // Stop it from repeating over and over
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);

private void timer_Elapsed(object sender, ElapsedEventArgs e)
{
    transform.Rotate(new Vector3(0, 0, 1) * Time.deltaTime);
}

您的密码:

if (isRolling) 
{
    transform.position += new Vector3 (0,1,2)
    timer.Start(); // Will wait the "Interval" milliseconds and fire off Elapsed (above)
}