- Home /
[NEWBIE]How to destroy a WheelCollider ? (with a script)
Hello everyone, I'm new to unity, I'm running to create a game, everything goes well but I do not know how to remove a wheelcollider. Let me explain: In my game there is a bug, when I turn over my car, the wheel collider are multiplying like:
//LeftFront_WheelCollider
LF_WheelCollider(clone)
LF_WheelCollider(clone)(clone)
LF_WheelCollider(clone)(clone)(clone)
LF_WheelCollider(clone)(clone)(clone)(clone)
...
And that the execution of the game slowed considerably so my question is: How, through a script I could remove a WheeCollider?
My condition would be: wheelCollider if (clone) = true then destroy wheelCollider (clone)
But I do not know how to transcribe into his script and if it's the solution for my problem.
I've never coded in Java or C # or but I know lua coding.
I tried to write a script but it nothing happens.
#pragma strict
var LF_WheelColliders : WheelCollider;
function Start(){
}
function Update () {
}
function destroy(other:Collider){
if (LF_WheelColliders == true) {
Destroy(LF_WheelColliders);
}
}
Thanks everyone
Sorry: Translation by Google
I think you should attempt to not create them in the first place so you don't have to remove them. Why are they being cloned? Are you adding them via code?
Answer by sofiane13240 · Jul 08, 2012 at 04:02 PM
It's good, I just solved the problem thank you very much.
For people who have the same problem as me, the problem is WheelAlign (script) is not good, take WheelAligment_script that works wonders.
http://www.youtube.com/watch?v=DCKTLRZa8_E
Link in the description.
Your answer
Follow this Question
Related Questions
destroy parent of script 1 Answer
Destruct gameobject by call from another script 1 Answer
DestroyObject is not destroying everything. 1 Answer
shuriken auto destruct script doesn't ALWAYS work? 2 Answers
Script to destroy object 1 Answer