Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Unity AI Programming Essentials

You're reading from   Unity AI Programming Essentials Use Unity3D, a popular game development ecosystem, to add realistic AI to your games quickly and effortlessly

Arrow left icon
Product type Paperback
Published in Dec 2014
Publisher
ISBN-13 9781783553556
Length 162 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Curtis Bennett Curtis Bennett
Author Profile Icon Curtis Bennett
Curtis Bennett
Arrow right icon
View More author details
Toc

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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime