Cover
Copyright
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Table of Contents
Preface
Chapter 1: The Basics of AI in Games
Creating the illusion of life
Leveling up your game with AI
Using AI in Unity
Defining the agent
Finite State Machines
Seeing the world through our agent's eyes
Path following and steering
Using A* Pathfinding
Using navigation mesh
Flocking and crowd dynamics
Behavior trees
Thinking with fuzzy logic
Summary
Chapter 2: Finite State
Machines and You
Finding uses for FSMs
Creating state machine behaviors
Creating the AnimationController asset
Layers and Parameters
The animation controller inspector
Bringing behaviors into the picture
Creating our very first state
Transitioning between states
Setting up our player tank
Creating the enemy tank
Choosing transitions
Making the cogs turn
Setting conditions
Driving parameters via code
Making our enemy tank move
Testing
Summary
Chapter 3: Implementing Sensors
Basic sensory systems
Cone of sight
Hearing, feeling, and smelling using spheres
Expanding AI through omniscience
Getting creative with sensing
Setting up the scene
Setting up the player tank and aspect
Implementing the player tank
Implementing the Aspect class
Creating an AI character
Using the Sense class
Giving a little perspective
Touching is believing
Testing the results
Summary
Chapter 4: Finding Your Way
Following a path
The path script
Using the path follower
Avoiding obstacles
Adding a custom layer
Implementing the avoidance logic
A* Pathfinding
Revisiting the A* algorithm
Implementation
Implementing the Node class
Establishing the priority queue
Setting up our grid manager
Diving into our A* implementation
Implementing a Test Code class
Setting up our sample scene
Testing all the components
Navigation mesh
Setting up the map
Navigation Static
Baking the navigation mesh
Using the NavMesh agent
Setting a destination
The Target class
Testing slopes
Exploring areas
Making sense of Off Mesh Links
Using the generated Off Mesh Links
Setting the manual Off Mesh Links
Summary
Chapter 5: Flocks and Crowds
Learning the origins of flocks
Understanding the concepts behind flocks and crowds
Flocking using Unity's samples
Mimicking individual behavior
Creating the controller
Using an alternative implementation
Implementing the FlockController
Using crowds
Implementing a simple crowd simulation
Using the CrowdAgent component
Adding some fun obstacles
Summary
Chapter 6: Behavior Trees
Learning the basics of behavior trees
Understanding different node types
Defining composite nodes
Understanding decorator nodes
Describing the leaf node
Evaluating the existing solutions
Implementing a basic behavior tree framework
Implementing a base Node class
Extending nodes to selectors
Moving on to sequences
Implementing a decorator as an inverter
Creating a generic action node
Testing our framework
Planning ahead
Examining our scene setup
Exploring the MathTree code
Executing the test
Summary
Chapter 7: Using Fuzzy Logic to Make Your AI Seem Alive
Defining fuzzy logic
Picking fuzzy systems over binary systems
Using fuzzy logic
Implementing a simple fuzzy logic system
Expanding the sets
Defuzzifying the data
Using the resulting crisp data
Using a simpler approach
Finding other uses for fuzzy logic
Merging with other concepts
Creating a truly unique experience
Summary
Chapter 8: How It All Comes Together
Setting up the rules
Creating the towers
Making the towers shoot
Setting up the tank
Setting up the environment
Testing the example
Summary
Index