- Home /
Assigning wheel collider of a spawned car to variable using script
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();
}
Answer by falconer · Apr 01, 2013 at 03:25 PM
I found the answer, just incase anybody comes across the same issue, here's the soultion
var myWC : WheelCollider;
function Start() {
myWC = transform.Find("/car1(Clone)/WheelCOlliders/ColliderFR").collider as WheelCollider;
}
Your answer
Follow this Question
Related Questions
Spaw dynamic (unregistered) object on network (UNET) 0 Answers
Database solution networking 0 Answers
No appropriate version of 'UnityEngine.Object.Instantiate' 0 Answers
Unity Photon syncing objects 0 Answers
MLAPI spawn player prefab 2 Answers