File > Build Settings > Architecture
).Color Space
under Project Settings > Player to Linear
.wheel
in the name (script uses the name to detect the wheels automatically, case is ignored).Adjusting physics settings is optional but it can increase the simulation quality of the vehicles:
Fixed Timestep
from default 0.02 (50Hz) to 0.01667 (60Hz). This will result in smoother physics behavior. If the game is aimed at mobile devices this value can be set to higher than 0.02 (e.g. 0.025 or even 0.03) but can cause instability at high speeds and vehicle jitter if too high. This setting affects performance.
To set up a vehicle automatically and skip the steps below, VehicleSetupWizard
can be used.
Make sure you vehicle has correct pivots and rotation first. Then, attach VehicleSetupWizard
to the root object of the vehicle - where the Rigidbody would normally be placed. Follow the steps from the wizard inspector and the vehicle will be up and running shortly.
VehicleSetupWizard
logs all of its actions in the console along with any errors and/or warnings. Make sure to check for those and correct them manually if needed.
Vehicle Setup Wizard does NOT set up scene input. For that check Input Setup page.
Rigidbody
component to the vehicle root, Car
in the image above. Set the mass to a reasonable value, e.g. 1400.Collider
(BoxCollider
, MeshCollider
, etc.) to the vehicle. WheelControllerIgnore
to all vehicle colliders. This will prevent wheels detecting the vehicle as ground. Do not use Default
layer or any of the ground layers or they will not be detected by the wheel!
For a vehicle to function first of all it needs wheels. NWH Vehicle Physics uses included asset WheelController
for this instead of default WheelCollider
. For more info check out WheelController Setup page.
WheelController
needs to be attached to a separate object from the wheel. That object will act as a suspension anchor and will represent the beginning of spring travel. Therefore, it needs to be positioned above the wheel center. Easiest way to create those objects is to duplicate the existing wheel objects, remove all components except Transform
from them and move the duplicated objects slightly above the wheel center.WheelController
component to the objects created in the previous step. WheelController
will initialize itself with default values and will try to set the necessary fields automatically. Check if the following fields are set:Parent
- root object of the vehicle. Must have Rigidbody
attached. Car for this example.Visual
- wheel model. Wheel_FL, Wheel_FR, etc. for this example.Width
and Radius
of WheelController
until they fit the wheel model.Rigidbody
set up with correct mass and at least one Collider
attached to the vehicle. For more info check Troubleshooting section of WheelController Setup page.The guide above is recommended for understanding of how input works. Below are the 'quick' steps needed:
InputSystemVehicleInputProvider
.InputSystemSceneInputProvider
.InputManagerVehicleInputProvider
.InputManagerSceneInputProvider
.Camera
as a child of vehicle object (right click ⇒ Camera) and attach CameraFollow
component to it.Target
.VehicleController
component to the vehicle root - where Rigidbody
is.VehicleController
will automatically set up default values and automatically set up Differential
s, Wheel
s and WheelGroup
s. Check console for output.Settings
tab and click on Validate Setup
button to for automatic validity check.