Developing the basic game structure
For this demo, we will write an AI for the free tutorial game TANKS!. You can download the base game from Unity Asset Store (https://assetstore.unity.com/packages/essentials/tutorial-projects/tanks-tutorial-46209
), or follow along with the version included in the Chapter 12
folder of this book's GitHub repository. The version included with this book has the advantage of already having been tested for Unity 2022.
In either case, the game is the same. When we start the game, we see a pleasant desert scenario, with rocks, structures, palm trees, and so on. Using the keyboard, we should be able to control the blue tank (the tank moves with W, A, S, and D and shoots with the Spacebar).
The following screenshot shows the basic structure of the game:
The first time you start with an existing project, spend as much time as you can familiarizing yourself with the game structure...