- Home /
Increase car controller acceleration
Hi, I want to add a car to my game with a simple arcade-style controls. I'm using the car controller from standard assets but the problem is that if I use default settings, car has pretty slow acceleration so it takes some time to reach desirable speed and stop if I use brakes. I want to have a car with not very high speed but with very high acceleration so that the controls feel more responsive.
So far I've tried increasing full torque over all wheels, reverse torque, top speed, setting car's mass to a low value and tweaking other settings but still, my car feels very heavy. Any advice is appreciated.
Answer by Honorsoft · Mar 17, 2018 at 09:02 PM
If you want to change the car physics(speed, acceleration, torque, etc.) there are settings that can be changed in the hierarchy of the wheels(WheelsHubs), there is also a script in the Scripts folder of the car's assets(CarController.cs). Those can be altered to try to get the results you're looking for.
I'm just working on this now. I originally started by making my own car (body, wheels, colliders, etc), but decided to try out the Standard Asset version of the Car controller and prefabs. At first, I was pleased at all the stuff that was done for me, such as brake lights, skid marks, engine pitch, etc. But after testing it a bit, found bunch of errors, glitches and flaws. Besides the unrealistic acceleration you mentioned, there is the skidding, sliding and spinning of the car when you try to turn, for some reason, Unity's default settings simulate driving a car on an extremely icy surface. There is also another flaw with the controller, if you come to a full stop using the handbrake, the car will 'lock-up' and you won't be able to drive forward until you drive in reverse first. Also the Diffuse texture for the car is missing, the low-deceleration audio clip is not assigned properly, and there's a few more errors that I found and am still finding, but those are the major ones so far. It's a shame, because it is hard to fix this complicated car system without knowing exactly how it works and all the math involved and how it interacts with everything. So you have a lot of work ahead, either spend a lot of time and study to fix Unity's car system, or spend a lot of time and study to make your own.
Everything you mention here is accurate and baffling.
Did you ever make a solution for the car locking up after using the handbrake?
Answer by Excelerator · Oct 26, 2017 at 07:53 AM
Add more force. Use an animation curve to map this force along velocity for more control.
Well it depends. I don't know anything about the car controller or when the force is added. If there is already a script, find where the add force funtion is. If it's only appliedwithin the wheel component, then you probably won't find it. You can still do it anyways with your own script. In your script, you reference your car body rigidbody, then use the rigidbody add force funtion to apply an offset force for each wheel. That offset would be the location of tire contact typically. The direction of force would be forwards or tangent of tire contact. You would then apply any logic to that amount of force depending if the tire is touching or if the throttle is applied. And then map out how much force you want via an animation curve along velocity. You just have to code one thing at a time untill you get what you want. If you choose a poorly made car controller asset, this is going to be more difficult or messy to code. But no matter what, as long as it uses PhysX, you are always allowed to use the add force function on your rigidbodies. You do this in fixed update.
Your answer
Follow this Question
Related Questions
Why my car fall over when I turn left or right?? 0 Answers
my car loses power over time? : o 0 Answers
Car steering issue 0 Answers
Collision Car Sensors 1 Answer
(Flat tutorial) Problem with pitch in car script [SOLVED] 0 Answers