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

Controlling AI with triggers


Chapter 5, Artificial Intelligence, deals with several methods to control AI in games. As we learned in that chapter, control and predictability are very important. Even if we have the smartest AI in the world, as programmers, we want to be able to know that the AI will perform a certain action at a certain time. This is where triggers can be extremely useful. In fact, with a good trigger system there might not be need for much AI at all.

One example of trigger usage might be a warehouse where guards are in a patrolling state. Once the player reaches a certain area (maybe where they should not go), an alarm is triggered. At this point, we also want the guards to switch to a more aggressive state.

Getting ready

This recipe will link the trigger system we created previously in the chapter with the StateMachine-based AIControl class from the Decision making – Finite State Machine recipe in Chapter 5, Artificial Intelligence. Even if you haven't followed the recipes...