Setting Up a Vehicle

Before setting up a vehicle, it is important to make sure that your project settings are in order and that a main camera exists as well as an instance of ControlScript.

In order to set up a new vehicle, first duplicate one of the template vehicles which most closely represents the one you wish to make. Template vehicles are in the folder Prefabs > Vehicles. Make sure to duplicate the prefab for editing and be careful to not alter the template prefab itself so you can use it later.

For the rigidbody, the default mass is 1000, the default drag is 0.1, and the default angular drag is 0.05. There should be no interpolation and the collision detection should be discrete.

The VehicleParent script contains most of the parameters for tuning performance, the rest being in the CarWheelColScript scripts of the wheel colliders.

In the Start function of VehicleParent, the doppler level of all audio sources attached to the vehicle is changed to zero, but only if the ai variable of VehicleParent is set to false.

Objects
Standard Car - The actual vehicle, read VehicleParent for more info.

axlefront - The front axle of the vehicle. This is what you should move if you want to move the wheels forward and back or up and down. This will guarantee that the wheels will stay on the same axis. Axle's should be moved up to their maximal compressed position in the editor.

wheel - The object containing both the wheel collider and mesh of a wheel. Move this object if you want to make the axle wider or narrower.

carwheel - The visual representation of a wheel, read CarWheelScript for more info. Do not move this directly.

hitSnd - The collision audio source for the wheel.

particleparent - The parent of the spark particle system for when the wheel is missing its tire.

Particle System - The actual spark particle.

popsnd - The audio source for when the tire pops.

screechsnd - The audio source for when the tire is skidding.

tire - The actual tire object.

wheelcol - The wheel collider of the wheel, read CarWheelColScript for more info. This object along with its children should be on the Ignore Raycast layer. Do not move this directly.

collider - One of the wheel's capsule colliders, read the WheelEnhance section of CarWheelColScript for more info.

axlerear - The rear axle.

boostflame - One of the boost flame particle systems.

boostsnd - The looping boost audio source.

booststartsource - The audio source for starting and ending a boost.

engine - The engine audio source, for more info on engine sounds, read VehicleParent and the section Engine Sounds below.

engineidle - The idle engine sound.

engineidleopen - The idle open engine sound.

engineopen - The open engine sound.

frontcol - The front collider of the vehicle, read the Colliders section below for more info.

hitsound - The collision audio source.

rearcol - The rear collider.

Renderer - The mesh renderer of the vehicle. Duplicate to add another renderer.

reversesnd - The whining sound of the reverse gear.

Shadow - The shadow projector of the vehicle. Move it up and down and change the properties to customize it to fit the vehicle. It is set to ignore everything on the Vehicle layer, so all renderers on the vehicle should be on this layer.

sparkparent - The parent of the collision spark particle.

Particle System - The actual spark particle.

undertray - The undertray collider.

whooshSnd - The whoosh audio source that plays when the vehicle spins in the air.

Adding or Deleting Wheels
To add more wheels, simply duplicate either one of the axle objects or wheel objects and drag the new wheelcol objects within them into the wheels array of VehicleParent. To delete wheels, delete an axle or wheel object and make sure to resize the wheels array of VehicleParent.

With a bike, the front wheel must be first in the wheels array, and the wheels must be in line with each other for the vehicle to behave as a bike.

Colliders
You can use any type of collider on a vehicle, except for non-convex mesh colliders. The undertray colliders are special colliders which go on the underside of a vehicle. They must use the UndertrayPhysMat physic material in the Physic Materials folder and each one must be listed in the Undertray Colliders array of the VehicleParent script. Undertray colliders have less friction and do not cause the vehicle to crash when collided against.

The Friction Colliders array of the VehicleParent script must contain all other colliders on the vehicle excluding those related to the wheels. Friction colliders have increased friction during crashes. The vehicle itself is in the friction colliders array because there is a collider attached to it.

Notice in the image above how the collider at the bumper of the car is rounder than the car mesh itself. This helps to prevent the car from catching on curbs and bumps and allows it to drive over them more smoothly. This is why I would not suggest using box colliders on a vehicle. Instead you should create a low poly version of the vehicle and bevel the edges on the front, rear, and bottom. Avoid creating nooks and crannies which could hook onto things. Remember that the mesh colliders must be convex and have 255 triangles or less.

Engine Sounds
The engine sounds built into this package use 4 separate audio sources each playing slightly different versions of the same sound. These 4 audio sources are named engine, engine idle, engine open, and engine idle open. These audio sources should be placed wherever the engine of you vehicle is.

Engine and engine idle sounds are loudest when viewing a vehicle from the side opposite the vehicle's grille, and engine open and engine idle open sounds are loudest from the side with the grille. This is indicated with the engineDirection variable of VehicleParent. The variable bilateralEngineSound of VehicleParent will make the open sounds louder from the negative engineDirection along with the positive direction. This is shown with a red line in the scene view when a vehicle is selected.

The idle sounds are louder when the vehicle's rpms are lower, and the non-idle sounds become louder as the rpms increase.

The engine audio source contains the base engine sound. The engine open audio source contains the same audio clip with the higher frequencies amplified. You can use a free audio editor such as Audacity to do this. The engine idle audio source contains the engine sound with the higher frequencies muffled instead, and the whole sound is made quieter as well. The engine idle open audio source contains the engine open sound, but quieter and with only the very highest frequencies muffled.

If you have Unity Pro you can simply use a single audio source with high pass and low pass filters applied and get the same result, but this claim is untested. This feature may come in a future version.