File > Build Settings > Architecture).
Color Spaceunder Project Settings > Player to
wheelin 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 Timestepfrom 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.
Rigidbodycomponent to the vehicle root,
Carin the image above. Set the mass to a reasonable value, e.g. 1400.
MeshCollider, etc.) to the vehicle.
WheelControllerIgnoreto all vehicle colliders. This will prevent wheels detecting the vehicle as ground. Do not use
Defaultlayer 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.
WheelControllerneeds 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
Transformfrom them and move the duplicated objects slightly above the wheel center.
WheelControllercomponent to the objects created in the previous step.
WheelControllerwill 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
Rigidbodyattached. Car for this example.
Visual- wheel model. Wheel_FL, Wheel_FR, etc. for this example.
WheelControlleruntil they fit the wheel model.
Rigidbodyset up with correct mass and at least one
Colliderattached 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:
Cameraas a child of vehicle object (right click ⇒ Camera) and attach
CameraFollowcomponent to it.
VehicleControllercomponent to the vehicle root - where
VehicleControllerwill automatically set up default values and automatically set up
WheelGroups. Check console for output.
Settingstab and click on
Validate Setupbutton to for automatic validity check.
This asset uses Assembly Definition (.asmdef) files. There are many benefits to assembly definitions but a downside is that the whole project needs to use them or they should not be used at all.
Using LogitechSDK (which does not fature assembly definitions) will therefore require an addition of .asmdef file inside the LogitechSDK directory and a reference inside NWH.VehiclePhysics2.VehicleController or removal of all .asmdef files from the asset if you do not wish to use assembly definitions.