0

在进行控件时,我遇到了以下错误。

Assets/Car/Scripts/NewBehaviourScript.js(78,22): UCE0001: ';' expected. Insert a semicolon at the end.

Assets/Car/Scripts/NewBehaviourScript.js(78,10): BCE0044: expecting (, found 'ShiftGears'.

Assets/Car/Scripts/NewBehaviourScript.js(79,9): BCE0043: Unexpected token: if.

Assets/Car/Scripts/NewBehaviourScript.js(79,41): UCE0001: ';' expected. Insert a semicolon at the end.

这些错误通常不会出现在统一的 sxripting 中,这是我第一次遇到它。这是我的代码

#pragma strict

var FrontLeftWheel : WheelCollider;
var FrontRightWheel : WheelCollider;
var BackLeftWheel : WheelCollider;
var BackRightWheel : WheelCollider;

var gasButton : GUITexture;
var breakButton : GUITexture;
var leftTurnButton : GUITexture;
var rightTurnButton : GUITexture;

var motorInputTouch : int = 0;
var breakPower : float = 200; 

var GearRatio : float[];
var CurrentGear : int = 0;

var EngineTorque : float = 230.0;
var MaxEngineRPM : float = 3000.0;
var MinEngineRPM : float = 1000.0;
private var EngineRPM : float = 0.0;

function Awake() {
    gasButton = GameObject.Find("Gas_Pedal").guiTexture;
breakButton = GameObject.Find("brake_Pedal").guiTexture;
leftTurnButton = GameObject.Find("Left_Turn_Button").guiTexture;
rightTurnButton = GameObject.Find("Right_Turn_Button").guiTexture;
}

function start() {
rigidbody.centerOfMass += Vector3(0, -1, .25);
}
function update() {
for (var touch : Touch in Input.touches)
    {
    if (touch.phase == TouchPhase.Stationary && gasButton.HitTest (touch.position)){
        motorInputTouch = 1;
    }
    else if (touch.phase == TouchPhase.Ended && gasButton.HitTest){
        motorInputTouch = 0;
    }
    if (touch.phase == TouchPhase.Stationary && breakButton.HitTest (touch.position)){
        breakPower = 200;
    }
    else if (touch.phase == TouchPhase.Ended && breakButton.HitTest){
        breakPower =  0;
    }
    if (touch.phase == TouchPhase.Stationary && leftTurnButton.HitTest (touch.position)){
        FrontLeftWheel.steerAngle = -15;
        FrontRightWheel.steerAngle = -15;
    }
    else if (touch.phase == TouchPhase.Ended && leftTurnButton.HitTest){
        FrontLeftWheel.steerAngle = 0;
        FrontRightWheel.steerAngle = 0;
    }
    if (touch.phase == TouchPhase.Stationary && rightTurnButton.HitTest (touch.position)){
        FrontLeftWheel.steerAngle = 15;
        FrontRightWheel.steerAngle = 15;
    }
    else if (touch.phase == TouchPhase.Ended && rightTurnButton.HitTest){
        FrontLeftWheel.steerAngle = 0;
        FrontRightWheel.steerAngle = 0;
    }

EngineRPM = (FrontLeftWheel.rpm + FrontRightWheel.rpm)/2 * GearRatio[CurrentGear];
ShiftGears();
audio.pitch = Mathf.Aba(EngineRPM / MaxEngine + 1.0);
if (audio.pitch > 2.0) {
audio.pitch = 2.0;
}
FrontLeftWheel.motorTorque = EngineTorque / GearRatio[CurrentGear] * motorInputTouch;
FrontRightWheel.motorTorque = EngineTorque / GearRatio[CurrentGear] * motorInputTouch;
//FrontLeftWheel.steerAngle = 10 * Input.GetAxis("Horizontal");
//FrontRightWheel.steerAngle = 10 * Input.GetAxis("Horizontal");

}
function ShiftGears() {
if ( EngineRPM >= MaxEngineRPM ) {
    var AppropriateGear : int = CurrentGear;
    for ( var i = 0; i < GearRatio.length; i++) {
        if (FrontLeftWheel.rpm * GearRatio[i] < MaxEngineRPM ) {
        AppropriateGear = i;
        break;
        }
    }
    CurrentGear = AppropriateGear;
}
if (EngineRPM <= MinEngineRPM ) {
    AppropriateGear = CurrentGear;

    for (var j = GearRatio.Length-1; j >= 0; j--) {
        if ( FrontLeftWheel.rpm * GearRatio[j] > MinEngineRPM ) {
            AppropriateGear = j;
            break;
        }
    }
CurrentGear = AppropriateGear;
}
}

这里有谁能帮我调试一下吗?多谢。

4

1 回答 1

0

您缺少右括号}。要么在 内结束你的 for 循环Update(),要么表示你的Update()函数结束。这会导致您看到的其余错误。

于 2013-09-07T09:37:31.147 回答