Book Image

Building a Game with Unity and Blender

Book Image

Building a Game with Unity and Blender

Overview of this book

In the wake of the indie game development scene, game development tools are no longer luxury items costing up to millions of dollars but are now affordable by smaller teams or even individual developers. Among these cutting-edge applications, Blender and Unity stand out from the crowd as a powerful combination that allows small-to-no budget indie developers or hobbyists alike to develop games that they have always dreamt of creating. Starting from the beginning, this book will cover designing the game concept, constructing the gameplay, creating the characters and environment, implementing game logic and basic artificial intelligence, and finally deploying the game for others to play. By sequentially working through the steps in each chapter, you will quickly master the skills required to develop your dream game from scratch.
Table of Contents (16 chapters)
Building a Game with Unity and Blender
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating basic artificial intelligence


Phew, we have come a long way, haven't we? But the most exciting part is just about to start—we will learn how to create basic game AI in Unity!

In a nutshell, artificial intelligence is all about making decisions autonomously based on a set of conditions and requirements. If a given condition has been met, then the AI will try to move from its current state to the other state that fits the criteria. This is what we call the finite state machine.

In order to know what conditions we need to set in our AI and what decisions it can make, we will design yet another flow chart for the AI:

In this chapter, we will only focus on the part where the AI will start chasing the player whenever the player is nearby. We will learn how to make the AI patrol around a given area in the next chapter, so stay tuned.

Before we start writing the code, we need to add a component called Nav Mesh Agent to our monster prefab. Without this component, our monster will lose the ability...