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!