Game Development Reference
In-Depth Information
Chapter 9. Driving
In this chapter, we will look at another specialized AI, driving. The other AI we have
looked at so far had pretty simple movement for characters. However, car movement
needs to take into account physics, and this makes driving AI more complex, which
is why we need an AI system specially designed for driving. The AI driving system
we will use for our demos is Smart Car AI. Smart Car uses Unity's built-in navigation
mesh system, so we will also take a look at it.
In this chapter, you will learn about:
• Setting up the AI driving system
• Creating a Unity navigation mesh
• Using Smart Car to drive AI along a path
• Using Smart Car to drive and avoid obstacles
An overview of driving
When designing AI for our characters, one of the basic concepts is to have AI move
withthesamerulesastheplayer.Ifyoueverplayedanyoldracinggames,sometimes
the opponent cars wouldn't follow the same physics as the player, zooming along un-
realistically and therefore creating a bad player experience. So, it's important to take
car physics into account, including the shape of the car and four wheels, and have
the AI move in the same way as the player. This is the main reason for using an AI
system especially designed for autos and driving, instead of a general-purpose game
AI system we have been using such as RAIN.
The driving system we'll use is Smart Car AI by BoneBreaker, which at the time of
writing this topic is available in Unity Asset Store for $10. It takes into account phys-
ics for the car and uses ray casting to sense the car's environment. It actually uses
two systems for navigation, which are Unity's built-in navigation system to determine
paths along a road and ray casting to sense obstacles and make adjustments to the
car.
Additionally, Smart Car uses four-wheel physics for realistic movement. Because of
the advanced use of physics, we can't just drop any car model in and have it work
automatically; we will need to configure Smart Car to use the model's wheel colliders.
Search WWH ::




Custom Search