Hello, I’m working on a network multiplayer car game. I want to stop the car after the car reaches a deadline. For that I’m checking if the wheel collider hits the plane used for the deadline. Now since I’m using spawning, a clone car comes into the scene whenever I start a new server or connect to the existing one. How can i assign the wheel collider to the variable using script?
here’s the code that i’m using to check if the race is finished:
var pastTime : float;
var myWC : WheelCollider;
private var isFinished : boolean = false;
var guiTime : GUIText;
function Update () {
var hit : WheelHit;
if(myWC.GetGroundHit(hit)) {
if(hit.collider.gameObject.tag == "finish") {
isFinished = true;
}
}
if(!isFinished) {
pastTime += Time.deltaTime;
}
guiTime.text = pastTime.ToString();
}