如果我回到最后一个重生点,我该如何重置我的车辆运动?

时间:2014-02-18 12:16:08

标签: unity3d unityscript

function OnTriggerEnter(col : Collider){
if(col.tag == "Player")
{
player.transform.position = SpawnPoint.position;

audio.PlayOneShot(Sound);
VioSign.enabled = true;
if(pauseEnabled == false){
        pauseEnabled = true;
        AudioListener.volume = 1;
        Time.timeScale = 0;
        Screen.showCursor = true;
    }
}
}

这是我的respawnpoint脚本。

#pragma strict
var wheelFL : WheelCollider;
var wheelFR : WheelCollider;
var wheelRL : WheelCollider;
var wheelRR : WheelCollider;
var maxTorque : float = 50;

function Start(){
rigidbody.centerOfMass.y = -0.9;
}


function FixedUpdate () {
wheelRR.motorTorque = maxTorque * Input.GetAxis("Vertical");
wheelRL.motorTorque = maxTorque * Input.GetAxis("Vertical");
wheelFL.steerAngle = 20 * Input.GetAxis("Horizontal");
wheelFR.steerAngle = 20 * Input.GetAxis("Horizontal");

}

这是我的汽车控制脚本我想在再次重生到重生点后停下车。我很难解决它。请帮帮我:)。

1 个答案:

答案 0 :(得分:1)

如果您只是想停止汽车的当前运动,您可以简单地将其速度设置为零:

function OnTriggerEnter(col : Collider){
if(col.tag == "Player")
{
player.transform.position = SpawnPoint.position;
player.gameObject.rigidBody.velocity = Vector3.zero;

audio.PlayOneShot(Sound);
VioSign.enabled = true;
if(pauseEnabled == false){
        pauseEnabled = true;
        AudioListener.volume = 1;
        Time.timeScale = 0;
        Screen.showCursor = true;
    }
}
}