O'Reilly logo

jMonkeyEngine 3.0 Cookbook by Rickard Edén

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a trigger system

Almost all story-driven games require some kind of system to trigger some sort of event for example, dialogs, enemies, or doors opening. Unless the game is very small, you generally don't want to hardcode these. The following recipe will describe a trigger system, which can be used for almost any type of game from FPSs to RTSs and RPGs.

We'll start out by laying the ground work with an AppState controlling all the script objects and the basic functionality of a Trigger class. Then, we'll look into how to actually activate the trigger and use it for something.

Getting ready

Before we start with the actual implementation, we create a small interface that we will use for various scripting scenarios. We call it ScriptObject ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required