Quantcast
Channel: Questions in topic: "wheelcollider"
Viewing all articles
Browse latest Browse all 490

Wheel collider - Accelerating after reversing doesn't change direction...

$
0
0
I have been playing with this for 3 days now with no success. I have a vehicle with several states. Accelerate, brake and reverse. If I brake after accelerate that works great. If I reverse after accelerating that is also fine. But if I accelerate after I have started reversing then I CONTINUE to reverse even faster rather than slow down, and start accelerating again. I assume it's because I don't know how torque works exactly. Any help would be appreciated! Sorry about the formatting I don't exactly know how to post the code yet! if (carScript.brakeIs) { if (carScript.currSpeed > 0) { WheelBrake(); } else { Reverse(); } } else { if (carScript.leftStickMagnitude > 0.1f && !carScript.brakeIs) { Accelerate(); } } void WheelAccel() { print("Accelerating!"); wheel.motorTorque = carScript.setAccel; wheel.motorTorque = carScript.setAccel; wheel.brakeTorque = 0; wheel.brakeTorque = 0; } void WheelBrake() { print("Braking!"); wheel.motorTorque = 0; wheel.motorTorque = 0; wheel.brakeTorque = carBaseScript.brakesTorque; wheel.brakeTorque = carBaseScript.brakesTorque; } void WheelReverse() { print("Reversing!"); wheel.motorTorque = -carBaseScript.reverseTorque; wheel.motorTorque = -carBaseScript.reverseTorque; wheel.brakeTorque = 0; wheel.brakeTorque = 0; }

Viewing all articles
Browse latest Browse all 490

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>