2014-02-18 37 views
0
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"); 

} 

這是我的車控制腳本我想再次重生的重生點後,把車停下來。我很難解決這個問題。請幫我:)

+0

多久做ü想停下來的車? – Nick

回答

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; 
    } 
} 
} 
+0

謝謝很多朋友:) – user3323352

相關問題