如何连续几次缓慢地改变位置?

时间:2019-05-19 09:44:04

标签: c# unity3d

我刚开始学习C#。 我知道有很多教程展示了如何缓慢地改变位置,但是我尝试了很多不同的方法,但是这些都不适合我。 我想连续一段时间慢慢改变位置。

int[] arrayX = new int[] { 3, 0, 0 };
int[] arrayY = new int[] { 2, 4, 6 };

void SetTransformX (double x, double y, double z) {

    transform.position = new Vector3 (x, y, z);

}

void Update () {

    foreach (int i in arrayX) {
        foreach (int l in arrayY) {

            double x = i + 0.3;
            double y = l + 0.5;

            SetTransformX (x, 0.5f, y);
        }
    }
}

我现在收到一个错误: Assets / Chessman.cs(12,42):错误CS1503:参数3:无法从“ double”转换为“ float”

当我将所有双打更改为浮点数时,我得到:  将类型“ double”隐式转换为“ float”。存在显式转换(您是否缺少演员表?)

0 个答案:

没有答案