- Home /
Stopping the car aftert he finish line?
Hello, I'm using the car demo as a reference to create a racing game of my own. I figured out how to stop the car after the finish line by using the below javascript code var carIsFinished : boolean = false; function Start() { carIsFinished = false; } function Update() { var hit : WheelHit;
if(myWC.GetGroundHit(hit)) { if(hit.collider.gameObject.tag == "finish") { carIsFinished = true; }}
if(carIsFinished == false)
{
GetInput();
}
}
COuld someone convert this into c# code?
Answer by iwaldrop · Feb 10, 2013 at 06:41 AM
The amazing thing is, that you script will pretty much work out of the box in C#, but since there were some things you could do to make it a bit more elegant, I thought I'd do that for you so you can compare what you had, how much extra work you were doing, and what it really needed. Enjoy.
void Update()
{
WheelHit hit;
if (myWC.GetGroundHit(hit) && hit.collider.gameObject.tag == "finish")
enabled = false;
GetInput();
}
Your answer
Follow this Question
Related Questions
How add kilometre per hour system in car script,how to add kilometre per hour speed system in script 0 Answers
Tilting car on two wheels 1 Answer
how to rotate car to camera direction using wheel colliders. 1 Answer
Rotate car steer angle towards target direction 0 Answers
Speedometer rotation problem 1 Answer