Real-Time Strategy Plugin for Unreal Engine 4 extends the game framework provided by Unreal Engine with features that are common in real-time strategy games.
For this, we embrace the principle of composition over inheritance: Most features are implemented by the means of components to add to your actors, to allow for the most flexibility on your side when building your game, especially when it comes to combining the plugin with other third-party software.
Some things have been carefully added to the existing game framework however, as designed by Epic, and require a few steps to set up.
The plugin also ships with a few assets that are designed to get you started, e.g. with unit AI, but feel free to modify or replace them as you see fit.
Make sure View Plugin Content is enabled in your view options.
- Create a player controller deriving from
RTSPlayerController
. - Create a player state deriving from
RTSPlayerState
. - Create a game state deriving from
RTSGameState
. - Create a HUD deriving from
RTSHUD
. - Create a game mode deriving from
RTSGameMode
. - Use your player controller, player state, game state, and HUD in your game mode.
- Create an AI controller deriving from
RTSPawnAIController
. - Set the Pawn Behavior Tree Asset of the new pawn AI controller to
BT_RTSPawnBehaviorTree
. - Set the Pawn Blackboard Asset of the new pawn AI controller to
BB_RTSPawnBlackboard
. - Set the Acquisition Object Types of the new pawn AI controller to
WorldDynamic
(or whichever Object Type you're going to use in the collision settings of your units). - Create a player start deriving from
RTSPlayerStart
. - Create one or more resource types deriving from
RTSResourceType
, setting their names and icons to use in your UI. - Add the resource types to the
PlayerResourcesComponent
of your player controller.
Usually, players control a single pawn in Unreal Engine. However, in the case of real-time strategy games, players control many units from a camera perspective far out. Thus, the plugin works best when using a simple pawn with a normal camera whose location reflects what the player wants to see right now. Individual units are not directly possessed by the player controllers, but just "owned" by them.
- Create a pawn blueprint.
- Add a
Camera
component. - Set the Location of the
Camera
component as desired (e.g. X = 0, Y = 0, Z = 1500). - Set the Rotation of the
Camera
component as desired (e.g. X = 0, Y = -75, Z = 0). - Use the pawn as Default Pawn Class in your game mode.
- Bind the axis
MoveCameraLeftRight
(e.g. to Left and Right keys). - Bind the axis
MoveCameraUpDown
(e.g. to Up and Down keys). - Bind the axis
ZoomCamera
(e.g. to the mouse wheel axis). - At your
RTSPlayerController
, set the Camera Speed (e.g. to 1000). - At your
RTSPlayerController
, set the Camera Scroll Threshold (e.g. to 20). - At your
RTSPlayerController
, set Camera Zoom Speed, Min Camera Distance and Max Camera Distance as desired. - At your
RTSPlayerController
, set Double Group Selection Time to the number of seconds the player has for rapidly selecting the same control group to center the camera on it.
Many default input actions for real-time strategy games are already provided by the plugin. Given that you use an RTSPlayerController in your game mode, you can bind the following actions which should speak for themselves. Clearly, all of these bindings are optional.
At Edit > Project Settings > Engine > Input ...
- Bind the action
Select
(e.g. to left mouse button). - Bind the actions
SaveControlGroup0
toSaveControlGroup9
(e.g. to CTRL+0 to CTRL+9). - Bind the actions
LoadControlGroup0
toLoadControlGroup9
(e.g. to 0 to 9). - Bind the action
AddSelection
(e.g. to Left Shift). - Bind the action
ToggleSelection
(e.g. to Left Ctrl). - Bind the action
SelectNextSubgroup
(e.g. to Tab). - Bind the action
SelectPreviousSubgroup
(e.g. Shift + Tab).
- Bind the actions
SaveCameraLocation0
toSaveCameraLocation4
(e.g. to CTRL+F5 to CTRL+F9). - Bind the actions
LoadCameraLocation0
toLoadCameraLocation9
(e.g. to F5 to F9).
- Bind the action
IssueOrder
(e.g. to the right mouse button). This will enable typical smart orders, such as moving when right-clicking ground, and attacking when right-clicking enemies. - Bind the action
IssueStopOrder
(e.g. to the S key).
- Bind the action
ShowHealthBars
(e.g. to the LeftAlt key).
- Bind the action
CancelProduction
(e.g. to Escape). - Bind the action
ShowProductionProgressBars
(e.g. to the LeftAlt key).
- Bind the action
ConfirmBuildingPlacement
(e.g. to Left Mouse Button). - Bind the action
CancelBuildingPlacement
(e.g. to Right Mouse Button). - Bind the action
CancelConstruction
(e.g. to Escape). - Bind the action
ShowConstructionProgressBars
(e.g. to the LeftAlt key).
The plugin makes use of gameplay tags for enabling condition-based gameplay (such as whether a unit can be attacked or not).
At Edit > Project Settings > Project > Gameplay Tags, add DT_RTSGameplayTags
to the Gameplay Tag Table List.