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

Selecting units in RTS

In this recipe, we'll show you how the selection of units in an RTS can work and also implement functionalities to show you when a unit has been selected. We'll use AppState, which handles mouse selection and we will also create a new Control class to be used by any spatial we want to be made selectable. In the recipe, Control will display a marker at the feet of the selected spatial, but it can easily be extended to do other things as well.

Getting ready

This recipe will work fine if you have already started creating a game where you would like to select things by clicking on them or if you've completed the previous recipe. The least you will need for this recipe is a scene with something to click on. In the text, we will ...

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