Book Image

JMonkeyEngine 3.0 Cookbook

By : Rickard Eden
Book Image

JMonkeyEngine 3.0 Cookbook

By: Rickard Eden

Overview of this book

Table of Contents (17 chapters)
jMonkeyEngine 3.0 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Pathfinding – using NavMesh


Pathfinding can be done in many different ways, and in this recipe we'll look at how to use the NavMesh generated in the previous recipe for pathfinding. We'll use jMonkeyEngine's AI plugin, which has a pathfinder designed to navigate NavMeshes.

We achieve this using the Control pattern, and will also implement a way to generate paths in a thread-safe way separate from the main update thread, to not impact the performance of the application.

Getting ready

We'll need a scene with a NavMesh geometry in it. We also need to download the AI library plugin. Instructions on how to download a plugin in the SDK can be found in the Downloading the plugins section in Appendix, Information Fragments. The plugin is called jME3 AI Library. Once we have downloaded the plugin, we need to add it to the project. Right-click on the project and select Properties, then select Libraries, and then select Add Library.... Select jME3 AI Library and click on Add Library.

How to do it...

We...