This is a full Manual and Documentation for the Unity Any Car Controller. It will cover all features, uses and set up procedures.

Set up a car controller in Unity as never been so simple and quick and it literally takes 1 minute.

The script is adaptable to any car model. Only necessary requirement is that the wheels must be separated objects from the car body and their pivot point must be on the relative wheel position.

Also if you want to use the Damage System, make sure you tick the Read/Write Enabled Check on the model. That will allow you to Deform the mesh.

  • Drag and Drop the AnyCarController Prefab into your Scene.
  • Drag and Drop your car model as a children of the “ModelParent” object in the Hierarchy.
  • Drag and Drop references of wheels and body into the appropriate fields of the AnyCarController component into the ControllerScript game object.
  • If your vehicle has more than 4 wheels add the number of the extra wheels you need into ExtraWheels > Size.
  • Drag and Drop the references for your extra wheels models and select whether you want the wheel to be front(steering wheels) or rear and whether you want them to be drive or trail wheels.
  • A consistent car body model is necessary to keep the wheels together and avoid bugs. In case you do not have that on your model PRESS the “CreateBodyCollider” Debug button and it will create a car body template.
  • Press “Attach Script” to complete set up.

Make a reference of the scene camera in the “Camera Reference” field.

Choose how many camera you want in your scene using the type of camera array and choose whether you want each camera to be in a fixed position or you want it to smoothly follow the car.

Press the “Create camera objects” button.

That will create your cameras into the scene. You can find these objects in the hierarchy under Utility>CamerasParent.

Position those object in the scene where you want the cameras to be relative to your car model.

Make a reference of the Steering Wheel model (it has to be a separate object) and press the button “Create steering wheel”.

Select the type of speedometer you want for your car (Analog/Digital).

Press create to display the selected speedometer & destroy to delete from your screen.

Select the type of Mobile UI you want for your car (Joystick/Arrows).

Press create to display the selected Mobile UI & destroy to delete from your screen.

Bare in mind that using the mobile UI will disable the keyboard controls.

The wheels attributes determine the actual physics of the wheels and suspensions of the car as well as drift settings.

Wheels Radius: Setting up the script the wheels will be created with the actual size of the wheels meshes. This parameter is a multiplier in case you want to adjust the wheel colliders size.

Wheels Mass: The Mass of the wheel.

Dumping Rate: This is a value of damping applied to a wheel.

Force Point: This parameter defines the point where the wheel forces will applied. When the parameter is zero the forces will be applied at the wheel base at rest.

Suspension Spring: A larger value makes the suspension reach the Target Position faster.

Suspension Dumper: Dampens the suspension velocity. A larger value makes the Suspension Spring move slower.

Suspension Distance: Maximum extension distance of wheel suspension, measured in local space. Suspension always extends downwards through the local Y-axis.

Target Position: The suspension’s rest distance along Suspension Distance. 1 maps to fully extended suspension, and 0 maps to fully compressed suspension.

Max Steer Angle: Steering angle in degrees.

Wheel Stiffness: Changes the stiffness of the friction. Setting this to zero will completely disable all friction from the wheel.

Steer Helper: Will change physics in order to make steering easier.

Traction Control: Will improve the traction of your car both on steering and accelerating.

Slip Limit: A lower value will make it easier for your car to slip.

The debug section is really only used for particular situations where the car model has no consistent pivot point and object structure and using this values you can put every bit back in the right position.

Wheel Position: It is a Vector3 Value and it determines the position of the actual wheel.

Wheel Rotation: It is a Quaterion Value and it is used in case the pivot points of your car models do not respect the directionality of the rest of the car. This can cause some strange behaviour of the wheels on runtime. This value is used to adjust this behaviour.

Car Drive Type: Front Wheels. Engine power will be applied only on front wheels. Rear Wheels. Engine power will be applied only on rear wheels. 4×4. Engine power will be distributed on all wheels.

Transmission: With Auto option the car will change gears automatically based on car speed. With manual user will have to change gears manually. The manual option will also give a clutch option that is merely the amount of time used to change gear.

Number of Gears: How many gears you want your car to have.

Engine Power: The value is represented with the power curve over time. It is basically how the motor Torque is distributed over time when accelerating.

Motor Torque: Motor torque on the wheel axle expressed in Newton metres.

Brake Torque: Brake torque expressed in Newton metres.

Reverse Torque: Reverse torque on the wheel axle expressed in Newton metres.

Handbrake Torque: Brake Torque only applied on rear wheels.

Down Force: This control will enhance the aerodynamics of your car giving more control on high speed.

Turbo: Activating the Turbo option will give your car a small extra power and it will enable the turbo sound (controllable from the audio tab of the Any Car Controller Script).

NOS: Activating the NOS on runtime, using the NOS Key, your Car will have a chosen extra power for a chosen amount of time. The NOS quantity will automatically recharge itself when it is not used. It will also activate the NOS sound, controllable from the audio Tab of the Any Car Controller Script.

Speed Type: Choose whether you want the speed of your car to be measured in MPH or KPH.

Max Speed: This value is based on speed type value and it will determine the maximum speed that the car can reach. Once it reaches it, the car will keep its speed still.

Vehicle Mass:  It controls the actual weight of the vehicle.

Center of Mass: It is a Vector3 value and it represent the point of maximum weight. It is often used to give the car more balance on steering.

BUTTONS

Skid Marks: This option will activate skid marks sound, marks renders and smoke on the floor when the wheels friction become particularly high.

Exhaust FX: This option will create a game obbject in the hierarchy. You will have to place this game object next to the exhaust pipe of your car model. It will make a firing visual effect and a exhaust sound when you will change  gear up with your car. You can control the audio volume in the audio Tab of the Any Car Controller Script.

ABS: This option will activate the Anti Brake-locking System.

Smoke: This option will activate smoke coming out of the car.

If you want to use the Damage System, make sure you tick the Read/Write Enabled Check on the model before you import the model into your scene. That will allow you to Deform the mesh.

Be aware that these values really varies depending on your car model.

If you are using a low poly model for instance decimal values will be enough to have a damage effect. With a high poly model you might need much higher number. You will have to test it yourself based on your model.

Demolution Strenght: How much will your car be destroyed based on collision.

Demolution Range: How big will be the damage on your car.

Collision Particles: Will create dusty effects on collision.

Custom Mesh: For more complex models this array will allow you damage only certain parts of your car on collision. It will also allow you to lose certain parts after a number of collisions that you can set in the array.

If you leave the number to zero you will not lose that part at all.

Choose whether you want to control your car with a keyboard or with a joystick.

Remember that if you are using a mobile UI these controls will be disabled.

If you are using the Standard Option for “steering”, “gas” and “brake”, it means that you are using X & Y Axis inputs for your car.

Otherwise you can just map your controls into keys or buttons.

Choose Audio Clips and volume for the Audio Fx.

The Engine Sound is a 4 channel Audio Effect. Choose sounds that you can loop and that simulate high and low RPM in accelerating and decelerating.

If you enable other functions in the Any Car Controller Script you will find other channels to control, such as:

  • Exhaust Audio
  • Skid Marks Audio
  • Turbo Audio
  • NOS Audio
  • Collision Audio

The Any Car Controller Prefab contains a Controller Script Object where all the magic happen.

Here you will find the script used to make references and to control physics and features.

This object contains 4 Childs: 

  • WheelsParent: Once the script is attached it will contain the wheel colliders.
  • Utility: Contains Front Lights, Rear Lights, Cameras Parent and if exhaust pipe is on Exhaust Object
  • UserInterface: Here you will find Mobile UI and speedometer if created.
  • ModelParent: Use this object as parent of your car model.

Hope you enjoyed. Feel free to contact me if you have any question, request or doubt.

Thanks for your attention on Any Car Controller (Car Physics) for Unity.

— BoolBird —