Class VehicleSetupWizard
Automated vehicle setup tool that configures a VehicleController from a 3D model. Can be used through the editor inspector or called at runtime via scripting. Requires a model with separate wheel GameObjects and Unity-correct scale (1,1,1), rotation, and pivots.
Namespace: NWH.VehiclePhysics2.SetupWizard
Assembly: NWH.VehiclePhysics2.dll
Syntax
public class VehicleSetupWizard : MonoBehaviour
Fields
addCamera
When enabled, adds a default vehicle camera with CameraMouseDrag component and CameraChanger to the vehicle.
Declaration
[Tooltip("Should a default vehicle camera and camera changer be added?")]
public bool addCamera
Field Value
| Type | Description |
|---|---|
| bool |
addCharacterEnterExitPoints
When enabled, creates left and right enter/exit points for character interaction with the vehicle.
Declaration
[Tooltip("Should character enter/exit points be added?")]
public bool addCharacterEnterExitPoints
Field Value
| Type | Description |
|---|---|
| bool |
height
Vehicle height in meters. Used for center of mass and inertia tensor calculation.
Declaration
public float height
Field Value
| Type | Description |
|---|---|
| float |
length
Vehicle length in meters. Used for inertia tensor calculation.
Declaration
public float length
Field Value
| Type | Description |
|---|---|
| float |
preset
Configuration preset that defines vehicle type-specific settings such as mass, power, suspension, etc.
Declaration
public VehicleSetupWizardPreset preset
Field Value
| Type | Description |
|---|---|
| VehicleSetupWizardPreset |
removeWizardOnComplete
When enabled, the VehicleSetupWizard component will be removed after successful setup completion.
Declaration
public bool removeWizardOnComplete
Field Value
| Type | Description |
|---|---|
| bool |
wheelGameObjects
List of wheel model GameObjects. For standard vehicles, add in order: front-left, front-right, rear-left, rear-right. For motorcycles, add in order: front, rear.
Declaration
[Tooltip("Wheel GameObjects in order: front-left, front-right, rear-left, rear-right, etc.")]
public List<GameObject> wheelGameObjects
Field Value
| Type | Description |
|---|---|
| List<GameObject> |
width
Vehicle width in meters. Used for inertia tensor calculation.
Declaration
public float width
Field Value
| Type | Description |
|---|---|
| float |
Methods
RunConfiguration(VehicleController, VehicleSetupWizardPreset)
Applies vehicle-type-specific configuration settings to a VehicleController using a preset. Configures mass, inertia, powertrain (engine, clutch, transmission, differentials), suspension, sound, and modules. Call this after RunSetup to tune the vehicle for a specific vehicle type (car, sports car, truck, motorcycle, etc.).
Declaration
public static void RunConfiguration(VehicleController vehicle, VehicleSetupWizardPreset preset)
Parameters
| Type | Name | Description |
|---|---|---|
| VehicleController | vehicle | The VehicleController to configure. |
| VehicleSetupWizardPreset | preset | Preset containing vehicle-type-specific settings such as mass, power, gearing, and suspension parameters. |
RunSetup(GameObject, List<GameObject>, bool, bool, float, float, float)
Creates a complete vehicle setup from a 3D model, adding all necessary components. This includes: Rigidbody, VehicleController, WheelControllers, camera (optional), and enter/exit points (optional). After running setup, call RunConfiguration to apply a VehicleSetupWizardPreset for vehicle-type-specific tuning.
Declaration
public static VehicleController RunSetup(GameObject targetGO, List<GameObject> wheelGOs, bool addCamera = true, bool addCharacterEnterExitPoints = true, float width = 1.8, float height = 1.5, float length = 4.5)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | targetGO | Root GameObject of the vehicle model. Must have scale [1,1,1] and at least one Collider. |
| List<GameObject> | wheelGOs | List of wheel model GameObjects in order: front-left, front-right, rear-left, rear-right, etc. |
| bool | addCamera | When true, adds a default vehicle camera with CameraMouseDrag and CameraChanger components. |
| bool | addCharacterEnterExitPoints | When true, creates left and right enter/exit points for character interaction. |
| float | width | Vehicle width in meters, used for inertia tensor calculation. |
| float | height | Vehicle height in meters, used for center of mass and inertia tensor calculation. |
| float | length | Vehicle length in meters, used for inertia tensor calculation. |
Returns
| Type | Description |
|---|---|
| VehicleController | The newly created VehicleController component if setup succeeds, or null if setup fails. |