- Home /
Sstop the car on reaching finished line [Problem
Hi guys .. i need your your help . why my car is not stop when the car is reaching finished? .. this is my code timer.js
var pastTime : float;
var myWC : WheelCollider;
static var isFinished : boolean = false;
var guiTime : GUIText;
function Update () { var hit : WheelHit;
if(myWC.GetGroundHit(hit)){ if(hit.collider.gameObject.tag == "finished") {
isFinished = true; } }
if(!isFinished) { pastTime += Time.deltaTime; }
guiTime.text=pastTime.ToString(); }
and this is my code update to CAR.js
function Update() {
var relativeVelocity : Vector3 = transform.InverseTransformDirection(rigidbody.velocity);
if(Timer.isFinished==false)
GetInput();
else throttle=0;
Check_If_Car_Is_Flipped();
UpdateWheelGraphics(relativeVelocity);
UpdateGear(relativeVelocity);
}
please guys help me .. thank you :)
First question what is throttle for ? If this variable should act on the car speed, it does not seem you use it.
As I understand by reading your code, it is relativeVelocity which fixes the car's movements. So maybe you should modify this value in the else case.
Your answer
![](https://koobas.hobune.stream/wayback/20220613140632im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
how dose this script look? 0 Answers
A node in a childnode? 1 Answer
accessing a variable from one script in another with Unity 1 Answer
Applying Damage to enemy script not working 1 Answer
Mouse axis wont change an integar. 1 Answer