-
Notifications
You must be signed in to change notification settings - Fork 18
Unit Selection
Jesus Bracho edited this page Jan 11, 2024
·
4 revisions
Unit selection is a bit of functionality unrelated to the camera, but since they often go together I added an implementation here for convenience.
- Add the
RTSSelectorcomponent to yourPlayer Controllerclass.

This component provides access to an array of Selected Actors which you can use to implement unit orders.

- In order to populate those selected actors we need to make use of the HUD. In the future I'd like to make this more composable, but HUD classes don't support component classes so for the time being I've provided a new HUD class. You'll want to create your own blueprint class as the
RTSHUDclass has plenty of hooks which can be overridden.

- Finally, in order to make actors in the scene selectable, their blueprints need to have an
RTSSelectablecomponent. You will also want to create your own blueprint class as this is how we customize the feedback when a unit is selected.

- In your own
RTSSelectable-derived blueprint, we can set up some quick and dirty feedbacks by overriding theOn SelectedandOn Deselectedevents.


- Add this custom blueprint to an actor in the scene.

- Now drag-select the character, and the On Selection event should fire (it might be a little tricky to catch them if you're using the Top Down starter package like I am).


- This is quite boring of course, so let's set up a unit highlighting system found in lots of traditional RTS games. First, start by adding a
Decalcomponent to the actor class containing your selectable component.

- Resize the decal to be facing down and near the actor's feet.

- I've included an example material
M_UnitSelectionfor convenience.

- Set the default visibility of the decal to be
false.

- Now, in your selectable blueprint, update the
On SelectedandOn Deselectedevents to the following to toggle the visibility of the Decal component. That should do it!

