motorTorque keeps on being applied
Hello Unity Answers!.. (So I already asked this question on the forums, but everything seems so dead on there. Is it the same thing on here? I hope not) Anyways..
So I got this script which is supposed to control my vehicle, which got 3 gears. Forward, neutral and backwards.
Although everytime I shift gear, it does not stop applying the motorTorque.
Here's what I've found out: Nothing to do with input (My axis's). (My old script works just as it should with Axis) Gear script work as it should As soon as I remove all these if conditions, it works as it should.
This is my gear shifting script. (See link)
This is alright. Just posting it for better understanding.
This is my primary motorscript. (See link)
As you can see, it should only drive forward when gear is in 2. (Or backwards when in 0)
At first when I start the game and the gear is set to 1 (which is neutral), it seems to work. As soon as I kick it in 2, it starts to drive forward slowly (As it should. idleMotor applies some torque to make it go slowly forward.)
But if I then shift it back to 1 (neutral) it just doesn't stop applying that torque from idleMotor. It keeps going forward. The same happens in the reverse gear, or if I speed it up with VerticalVehicle Axis.
Anyone able to find what I'm doing wrong? Feel free to ask for more information or explanation!
Thanks!
By doing some debugging myself, it does seem to be something affected by my gear script. Somehow, the input is not very responsive, and it takes several key presses, before it decides to actually switch gear.
Answer by mads232 · Dec 06, 2015 at 10:04 PM
I was calling my functions in fixedUpdate, so after changing that to Update, it stopped doing that. (derp)
Your answer
![](https://koobas.hobune.stream/wayback/20220612051318im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
OnCollisionEnter cant work with wheel colliders 1 Answer
good setting for WheelCollider 0 Answers
Wheel Colliers sinking into ground 1 Answer
WheelColliders problem 1 Answer
Wheel Collider 0 Answers