Add Colliders
Next you need to add Colliders to your Vehicle. To do this follow the steps below.
-
Add a child Object called
Colliders
to theEgoVehicle
Object. -
Shift parent Object
Colliders
accordingly as in earlier steps where we shiftedModels
.
Add a Vehicle Collider
-
Add a child Object
Collider
to theColliders
Object. -
Add a
Mesh Collider
component to theCollider
Object 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
Wheels
to theColliders
Object.
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
FrontLeftWheel
to theWheels
Object. -
Add a
Wheel Collider
component to theFrontLeftWheel
Object by clicking 'Add Component' and searching for it. -
Add a
Wheel
Script to theFrontLeftWheel
Object by clicking 'Add Component' and searching for it. -
Drag
FrontLeftWheel
Object from theWheelVisuals
to theWheel Visual Transform
field. -
Add a
Wheel Collider Config
Script to theFrontLeftWheel
Object by clicking 'Add Component' and searching for it. -
Configure the
Wheel Collider Config
Script so that the Vehicle behaves as you wish. -
Set the Transform of
FrontLeftWheel
Object 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.