Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Unity Artificial Intelligence Programming - Fifth Edition

You're reading from  Unity Artificial Intelligence Programming - Fifth Edition

Product type Book
Published in Mar 2022
Publisher Packt
ISBN-13 9781803238531
Pages 308 pages
Edition 5th Edition
Languages
Author (1):
Dr. Davide Aversa Dr. Davide Aversa
Profile icon Dr. Davide Aversa

Table of Contents (17) Chapters

Preface Part 1:Basic AI
Chapter 1: Introduction to AI Chapter 2: Finite State Machines Chapter 3: Randomness and Probability Chapter 4: Implementing Sensors Part 2:Movement and Navigation
Chapter 5: Flocking Chapter 6: Path Following and Steering Behaviors Chapter 7: A* Pathfinding Chapter 8: Navigation Mesh Part 3:Advanced AI
Chapter 9: Behavior Trees Chapter 10: Procedural Content Generation Chapter 11: Machine Learning in Unity Chapter 12: Putting It All Together Other Books You May Enjoy

Implementing the nodes

After we have made a plan for our BT, the next step is to check whether our BT implementation of choice (in our case, Behavior Bricks) already includes some of the nodes we need. Of course, we want to reuse as many pre-made nodes as possible. Reading the Behavior Bricks documentation, we can see that it already includes nodes such as IsTargetClose, MoveToGameObject, Wander, and AlwaysTrue, plus, of course, Repeat and Selector.

Therefore, we need to write all the other tasks. Note that Behavior Bricks tasks are not MonoBehaviors; therefore, we do not need to attach them to some object in the scene. We only need to put the scripts in any folder in our project's assets, and we are good. Let's look at a step-by-step process to do this:

  1. Let's start with the ShootOnce action by creating a ShootOnce.cs file in the project assets. First, we create a simple Action attribute called ShootOnce that, as the name says, shoots a single bullet:
    using...
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 $15.99/month. Cancel anytime}