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

Basic flocking behavior

As we said in the introduction to this chapter, we can describe a flocking behavior by using just three intuitive properties:

  • Separation: This property, also called short-range repulsion, represents the minimum distance between neighboring boids to avoid collisions. You can imagine this rule as a force that pushes a boid away from the others.
  • Alignment: This property represents the likelihood for each boid to move in the same direction as the flock (we measure this as the average direction of all the individual boids).
  • Cohesion: This property, also called long-range attraction, represents the likelihood for each boid to move toward the center of mass of the flock (we measure this by averaging the position of each boid in the flock). Thus, you can imagine this rule as a force that pushes a boid toward the center of the flock.

In this demo, we will create a scene with flocks of objects and implement the flocking behavior in C#. For this...

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}