Usually, you'll want to create a very individual user interface for your own game. However, some things are very common to real-time strategy games, such as health bars or minimaps, and we want to provide you a small head start at least, mostly by the means of events you can implement. As always, feel free to create your own UI widgets as you see fit - you should be able to apply them easily with the plugin.
In your HUD, implement the DrawSelectionFrame
and HideSelectionFrame
events as desired.
Example:
- Create a widget for drawing the selection frame.
- Add your widget to any kind of user interface your player controller knows about.
- In that user interface, provide a function for showing the selection frame.
- In the user interface, provide a function for hiding the selection frame.
- In your HUD, forward the
DrawSelectionFrame
event to your UI.
- In the HUD, forward the
HideSelectionFrame
event to your UI.
- Create a new widget blueprint.
- Create the widget where appropriate (e.g.
BeginPlay
of your player controller) and add it to your viewport. - Listen to the
OnSelectionChanged
event broadcasted by theRTSPlayerController
and update your UI.
- In your HUD, set Always Show Health Bars, Show Hover Health Bars, Show Selection Health Bars and Show Hotkey Health Bars as desired.
- Create a widget for drawing the health bar.
You might want to make sure that the visibility of the widget is set to Hit Test Invisible. Otherwise, it will block mouse input from your player.
- Create a component deriving from
RTSHealthBarWidgetComponent
, and set its Widget Class to your health bar widget. - Forward the
UpdateHealthBar
event to your health bar widget.
- Forward the
UpdatePositionAndSize
event to your health bar widget.
- Create a widget for drawing name plates (or whatever other information you'd like to display for hovered actors).
You might want to make sure that the visibility of the widget is set to Hit Test Invisible. Otherwise, it will block mouse input from your player.
- Create a component deriving from
RTSHoveredActorWidgetComponent
, and set its Widget Class to your new widget widget. - Forward the
UpdateData
event to your widget.
- Forward the
UpdatePositionAndSize
event to your widget.
- Create an actor deriving from
RTSBuildingCursor
(or use theBP_RTSBuildingCursor
shipped with the plugin). - If you want to use grid-based building placement, set the Grid Cell Size of your building cursor, and set up its collision and navigation check settings as desired.
- In your player controller, set the building cursor reference.
Note: When having your building cursor query navigation, you need to enable Allow Client Side Navigation in your project settings for this to work in multiplayer.
- Create an actor deriving from
RTSRangeIndicator
(or use theBP_RTSRangeIndicator
shipped with the plugin). - At your building cursor, set the range indicator reference.
- Use
GetAvailableProducts
of a selected production actor to create buttons for your production options (e.g. whenever the player controller raises OnSelectionChanged). - Call
IssueProductionOrder
of your player controller whenever one of these buttons is clicked.
- In your HUD, set Always Show Production Progress Bars, Show Hover Production Progress Bars, Show Selection Production Progress Bars and Show Hotkey Production Progress Bars as desired.
- Create a widget for drawing the production progress bar.
See the Health Bars section for an example.
- Create a component deriving from
RTSProductionProgressBarWidgetComponent
, and set its Widget Class to your progress bar widget. - Forward the
UpdateProductionProgressBar
event to your progress bar widget. - Forward the
UpdatePositionAndSize
event to your progress bar widget.
- Use
GetConstructibleBuildingClasses
of a selected builder to create buttons for your construction options (e.g. whenever the player controller raisesOnSelectionChanged
). - Call
BeginBuildingPlacement
of your player controller whenever one of these buttons is clicked.
- In your HUD, set Always Show Construction Progress Bars, Show Hover Construction Progress Bars, Show Selection Construction Progress Bars and Show Hotkey Construction Progress Bars as desired.
- Create a widget for drawing the construction progress bar.
See the Health Bars section for an example.
- Create a component deriving from
RTSConstructionProgressBarWidgetComponent
, and set its Widget Class to your progress bar widget. - Forward the
UpdateConstrutionProgressBar
event to your progress bar widget. - Forward the
UpdatePositionAndSize
event to your progress bar widget.
- Create a widget for showing your current resources.
- Handle the
OnResourcesChanged
event raised by thePlayerResourcesComponent
attached to your player controller to update your UI.
- Add the
WBP_RTSMinimapWidget
to your UI, with a size matching your minimap volume images (e.g. 256 x 256). - Set the Draw Background, Draw Units With Team Colors, Draw Vision and Draw View Frustum flags as desired.
- If you checked Draw Units With Team Colors, set the Own Units Brush, Enemy Units Brush and Neutral Units Brush as desired.
- If you want damaged units to blink on the minimap, set Damaged Units Blink Brush and Damaged Unit Blink Time Seconds as desired.
- In your HUD, enable Show Floating Combat Texts.
- Set Floating Combat Text Speed and Fade Out Floating Combat Texts as desired.
- Add a
RTSFloatingCombatTextComponent
to any actor that should be able to display texts above them. - Create an actor component for adding the actual floating combat texts.
- Add your actor component to all actors that should be able to add floating combat texts.
- In your HUD, handle the
DrawFloatingCombatText
event.