RTS Multiplayer Game Series

3.Select Units by Dragging a Rectangle



Create a BP HUD class, called RTS_Marquee_HUD
image.png
Create a BP Controller, name as RTS_Player controller

Go Project setting, change the default setting
image.png

To make the rectangle for selection:


Transfer the graph nodes created from tutorial 1 from BP_TopDown Controller to RTS controller
Untick Hide Cursor During capture in set input mode game and UI node
image.png
Create a boolean variable, form the graph below:
image.png

Create a BP interface, called RTS_Interface
Name and add the function as follow
image.png
Add RTS interface in RTS PlayerController
image.png
Add follow to the graph
image.png

Go to RTS marquee HUD,
class setting, add RTS interface
Add below variables:
image.png
go to event graph and set as below:
image.png

For drawing rectangle (rect color set alpha 0.2, like transparent)
image.png
image.png

To make the drawing rectangle interact on targeted objects:
Go to RTS interface, add
image.png
Go to Parent Unit Class
Add RTS interface, set the graph
image.png
Go to HUD BP, extend the graph from Draw Rect node:
image.png

To make De-selection:
In HUD BP, add actor array variable
image.png
image.png

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.