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.
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 refer to TestScene
, which was created in Chapter 1, SDK Game Development Hub, and the Jaime model which is used in it. It is assumed that you have some experience in action handling. If not, it's recommended that you refer to the Attaching an input...