Implementing an architecture for racing games
Racing games are really interesting to develop, and work on AI for the non-player drivers. They can be simple, or they can get really complex, as a car system really is tied to represent believable physics; however, there are minimum requirements for them to work, and to develop proper intelligent behaviors for non-player agents. In this recipe, we will learn how to create a small architecture for racing games.
Getting ready
We will use the driver profile object that we developed previously, and use this recipe as the cornerstone for the rubber-band system we will develop later.
How to do it...
Let's start by creating the interface to control the car. This interface is a MonoBehaviour
class with public members, so the player and the agents could interact with it easily and seamlessly:
- Create a new file and name it
CarController
, as shown in the following code:
using UnityEngine; public class CarController : MonoBehaviour { // next steps }
- Next,...