Book Image

Unity AI Programming Essentials

By : Curtis Bennett
Book Image

Unity AI Programming Essentials

By: Curtis Bennett

Overview of this book

Table of Contents (19 chapters)

RAIN's demo


The basic start of the demo will be similar to our others, a ground with several walls around for our ships to travel. This is how the basic starting point of our demo should look:

The basic starting point of our demo

One of the first things we will need is the ability to query a random location in the scene to spawn and find points to travel to. Create a class called Ground and add it to the ground plane. This class will be used to provide higher-level information about the level, the first of which is being able to find a random position in the level. Here is the Ground class with the random position chooser method:

In the preceding code, we are able to ask for a random position at anytime from anywhere in the game. In the Start method for the Ground class, we store the max and min positions for it, and as we don't want positions on the very edge of the level, it is scaled to 90 percent by multiplying by 0.9f. The min and max positions are static, so we can add a static method...