Book Image

Mastering Unity Scripting

By : Alan Thorn
Book Image

Mastering Unity Scripting

By: Alan Thorn

Overview of this book

Table of Contents (17 chapters)
Mastering Unity Scripting
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Baking a navigation mesh


The enemy to be created needs to walk intelligently around the level to find and chase the player as well as to find health-restore power-ups. The AI cannot simply walk in a straight line between any two points, as there might be intervening obstacles such as walls and other characters. The AI should instead navigate around these objects when they're encountered. To achieve this in the long term, a navigation mesh should be used. This is an invisible mesh asset that Unity generates automatically to approximate all walkable, horizontal surfaces in the level, that is, surfaces classified as a floor. The navigation mesh itself contains no AI. It does not make anything walk. The navigation mesh is rather a mathematical model that contains all the necessary data that allows AI units to successfully calculate and travel a path that avoids obstacles as and when required. To generate a navigation mesh for the level, select the Navigation option from the Window tab of the...