Java Unity错误

时间:2017-05-14 01:30:51

标签: android unity3d

我是java的新手并尝试运行一些示例代码。我收到以下错误

它说&#34 ;;"预期,插入;在每个变量的末尾插入分号

我想知道如何解决这个问题并让代码运行,谢谢!

#pragma strict
import UnityEngine;
import System.Collections;

public class Move 
{

    //A method that Unity uses to re-run the code every second
    function Update ()
    {
        double moveTime;
        double currentMoveTime;
        double perc = 1;
        //if the input is given from an android
        if ((Input.GetButtonDown("left") || Input.GetButtonDown("right") || Input.GetButtonDown("center")))
        {
            if (perc == 1)
            {
                moveTime = 1;
                currentMoveTime = 0;
            }
        }
        //Adjusting position
        startPos = gameObject.transform.position;
        if(((Input.GetButtonDown("right") && gameObject.transform.position == endPos)))
        {
            endPos = new Vector3(transform.position.x + 1, transform.position.y, transform.position.x);
        }
        if((Input.GetButtonDown("left") && gameObject.transform.position == endPos))
        {
            endPos = new Vector3(transform.position.x - 1,  transform.position.y, transform.position.x);
        }
        if((Input.GetButtonDown("center") && gameObject.transform.position == endPos))
        {
            endPos = new Vector3(transform.position.x,  transform.position.y, transform.position.x);
        }
        //Speed up move time after enough time passes
        currentMoveTime += Time.deltaTime * 5.5;
        perc = currentMoveTime / moveTime;
        gameObject.transform.position = Vector3.Lerp(startPos, endPos, perc);
    }
}

1 个答案:

答案 0 :(得分:0)

 You can't use Java in Unity.
 What you see is C#