Game Development Reference
In-Depth Information
the waypoints will be visualized in the edit or view to make adjusting their locations
easier. Refer to the following screenshot, and you can see how the visualization of
Smart car AI waypoints looks:
If you run the demo after setting the waypoints, the car drives realistically across the
road. If you want to fine-tune the car more, remember there are many physics set-
tings with Smart Car that can be adjusted to change how the car acts.
Adding obstacles to driving
As Smart Car uses a combination of a NavMesh and ray casting, you can add ob-
jects dynamically to the scene, and as long as they have colliders attached (and are
on a car's Recast Layers ), the car will avoid them. To try this out, add a few large
cylinders to the road, as shown in the following screenshot:
Then, in the Recast Layers dropdown for your car, make sure that it is set to ray
cast on the same layer as the obstacles. Select a Cylinder object and in Inspector ,
select Add Layer . We need to create an obstacles layer, so select the dropdown and
in the first slot for User Layer , set it to obstacles .
Then, for each cylinder, set its layer to obstacles :
Search WWH ::




Custom Search