Game Development Reference
In-Depth Information
Additional features
We've just completed creating a driving demo with a car avoiding obstacles, but there
are a few more things you can do with driving AI. We can add brake and drift zones to
help configure the general behavior of the car as it drives around the scene, and we
can integrate Smart Car with other AI systems such as RAIN.
Adding brake zones and drift zones
Another interesting thing you can do with Smart Car is define zones in the level to
either cause the car to brake and slow down or adjust the friction of the car to make it
drift. These are similar to the vector fields we saw in Chapter 5 , Crowd Control , where
we place them in the level to affect the AI, and they aren't visible to the player but
are good to use for scripting level experiences. To create a brake or drift zone in your
game, add a cube to the game (go to GameObject | Create Other | Cube ) and scale
and translate the area you want to tag in the level. In the Inspector window for the
cube, set its tag to BrakeZone and for a drift zone set the tag to DriftZone . Next, in
Box Collider for the cube, check Is Trigger to true, so the car will get a message of
intersecting with a cube but won't stop and collide with it. Lastly, in the Inspector win-
dow, uncheck Mesh Renderer so that the cube is invisible in the game. Now when
you run the demo, if the car's speed is 25 or over when it enters the brake zone, you
will see it slow down, and if its speed is 15 or over, you will see it drift in the drift zone.
Integrating with other AI systems
In this demo, we've seen that setting up an AI car that drives around is easy to do with
Smart Car. However, what if your game isn't just a driving game but has car driving
as one part of the game? If that's the case, you can mix Smart Car with another AI
system easily. For RAIN integration, import the RAIN package into your scene. Then,
go to RAIN | Create Entity and then select Add Aspect: Visual Aspects . This cre-
ates an entity with an aspect that can be sensed by additional RAIN AI entities you
can create in the scene, making the car just one part of a larger AI system.
Search WWH ::




Custom Search