Quick Setup
Learn how to set up the vehicle controller
Quick Setup Guide:
Full Setup Guide:
1. Setting up the controller
1. Open the editor window by going to Tools -> Custom Vehicle Controller -> Vehicle Editor.

An editor window should open:

1.1 Drag a vehicle model into the scene.

1.2. Select a root game object of your vehicle with the CustomVehicleController script attached.

1.3 Drag and drop references to the wheels and vehicle body MeshRenderers.

Wheel models must have a standard Unity orientation (Y - up, Z - forward, X - right)
Wheel objects must have the origin in the center of the mesh for correct rotation. Alternatively, you can parent each wheel to an empty GameObject, setting the wheel's local position correctly and then assign the parent gameobjects to the editor object fields. Note, however, that in this case you would have to set the wheel radius manually
1.4 Initialize the controller.

After clicking the "Initialize Controller" button, the hierarchy of game objects will be created, necessary scripts for the wheel physics added, script references populated, and, in case the wheel transform references have a MeshRenderer component, suspension position and wheel radius will be calculated.
If the selected game object is a prefab, you'll need to unpack it. If you try to initialize the controller on the prefab, a warning will be shown:
After clicking "Yes", the prefab will be unpacked completely and the controller will be initialized. You won't be able to initialize the controller as long as the selected game object is a prefab.
Now, the hierarchy should look like this:

The selected game object should have:
CustomVehicleController component - manages the vehicle behavior

CarVisualsEssentials component - manages wheels` rotation and position

Rigidbody

with references to newly created scripts and the center of mass assigned.
If you want to make the vehicle drive at high speed ( ≈ > 50 m/s), some changes to rigidbody settings must be made
2. Assign vehicle parts set
CustomVehicleController asset uses ScriptableObjects to represent the following vehicle parts:
Engine
Nitrous (optional)
Forced Induction (optional, part of the engine)
Transmission
Tires
Suspension
Brakes
Body
CustomVehicleController component expects either a VehiclePartsPresetSO, which is a scriptable object that holds references to the used vehicle parts:

Or individually set up vehicle parts:

With the vehicle initialized and the vehicle game object selected, open the editor window.
Make sure the "Use Presets On This Controller" toggle is turned on:

In the Preset Settings foldout, select any VehiclePartsPresetSO instance.

At this point, the vehicle should be set up completely. All that's left is input handling.
3. Player input
For handling player input, you are provided a script that uses old Unity's input system. Add it to the GameObject with the CustomVehicleController component.

Do not forget to add colliders to the vehicle if you haven't already.
If you use multiple colliders or a mesh colliders, additional set up is required. Read more here

You should have a car that drives.
Last updated