Game Development Reference
In-Depth Information
This is how the Inspector window should look after creating the obstacle layer.
Then, for Smart Carinthe Raycast Layers dropdown, makesurethat the obstacles
layer is selected. Once you have this set up, if you run the demo, the car will drive
and avoid the obstacles. The car still uses physics for its control, and sometimes
if you place the obstacles too close to one another, the car will run into one. For-
tunately, in this case, the car will back up and then drive past it, which is a nice touch
Smart Car has.
The cylinders are static objects in our scene, but as ray casting is used, there is no
reason why you cannot script dynamic objects and the car will still avoid them. To
see this, run the demo and in the scene view, grab one of the obstacles and move it
around to block the car; the car will try to avoid it.
Search WWH ::




Custom Search