Add Colliders
Next you need to add Colliders to your Vehicle. To do this follow the steps below.
-
Add a child Object called
Collidersto theEgoVehicleObject.
-
Shift parent Object
Collidersaccordingly as in earlier steps where we shiftedModels.
Add a Vehicle Collider#
-
Add a child Object
Colliderto theCollidersObject.
-
Add a
Mesh Collidercomponent to theColliderObject by clicking on the 'Add Component' button in the Inspector view and searching for it.
-
Click on the arrow in mesh selection field and from the pop-up window select your collider mesh. Next click on the check-box called
Convex, by now your collider mesh should be visible in the editor.
Add Wheel Colliders#
-
Add a child Object
Wheelsto theCollidersObject.
Note
In this tutorial we will add only one wheel collider, but you should repeat the step for all 4 wheels. That is, follow the instructions that follow this message for every wheel your Vehicle has.
- Front Left Wheel
- Front Right Wheel
- Rear Left Wheel
- Rear Right Wheel
-
Add a child Object
FrontLeftWheelto theWheelsObject.
-
Add a
Wheel Collidercomponent to theFrontLeftWheelObject by clicking 'Add Component' and searching for it.
-
Add a
WheelScript to theFrontLeftWheelObject by clicking 'Add Component' and searching for it.
-
Drag
FrontLeftWheelObject from theWheelVisualsto theWheel Visual Transformfield.
-
Add a
Wheel Collider ConfigScript to theFrontLeftWheelObject by clicking 'Add Component' and searching for it.
-
Configure the
Wheel Collider ConfigScript so that the Vehicle behaves as you wish.
-
Set the Transform of
FrontLeftWheelObject to match the visuals of your Vehicle.
Successful configuration
If you have done everything right your Colliders Object should look similar to the one following.
