Question by
tuhin_hossain · Mar 11, 2016 at 08:19 PM ·
scripting problemcar-tutorial
MotorTorque reversing not Working
When I make the "reverCounter < 2" its start reversing from the beginning but when I make "reverCounter > 2" and then when my car stuck in something it should reversing but it won't. What I did wrong with this code. Please help me.
if (Rb.velocity.magnitude < 2 && !reversing) {
reverCounter += Time.deltaTime;
if (reverCounter > 2) {
wheelRL.motorTorque = -maxTorque;
wheelRR.motorTorque = -maxTorque;
reverCounter = 0;
reversing = true;
}
} else if (!reversing) {
reverCounter = 0;
}
if (reversing){
avoidSenstivity = -1;
reverCounter += Time.deltaTime;
if (reverCounter >= 2){
reverCounter = 0;
reversing = false;
}
}
Comment
Your answer
Follow this Question
Related Questions
Hi guys, I need help with C# Scripting using Raycast. 1 Answer
Scene changing problem 1 Answer
Can't add script problem 1 Answer
instantiating problem??? 2 Answers
Question on Audio? 1 Answer