Strategy Camera: TBS / RTS camera blueprint for Unreal Engine 4.

Available at Gumroad
Video
Support email

Current version: 1.0.0
Supported UE4 versions: 4.14 - 4.16

Documentation

Overview

Strategy Camera is a Pawn based blueprint implementing TBS / RTS top down camera with all commonly required basic functionality.

PlayerController blueprint is provided with examples on how to move and wait for camera. 2 simple actor blueprints are provided with example of onClick move/teleport camera functionality.


Package use model

There are two ways you can use Strategy Camera package in UE4. If you wish to open provided Strategy Camera project simply extract package contents into your UE4 projects folder. Open UE4 launcher and you should see Strategy Camera project in your Library.

If you wish to add Strategy Camera to an existing project, copy StrategyCamera/Content/StrategyCamera folder from the package into your existing project Content folder. Be careful not to copy over StrategyCamera/Config folder as it may cause your existing .ini files get overwritten. Alternatively, if you put Strategy Camera project into your UE4 projects folder, you can open it and migrate StrategyCamera folder into an existing project.

If you want to add/migrate minimal required set of assets without sample level, here is the list of files you need:
Content/StrategyCamera/Blueprints/BP_GameMode.uasset
Content/StrategyCamera/Blueprints/BP_PlayerController.uasset
Content/StrategyCamera/Blueprints/BP_StrategyCamera.uasset
Content/StrategyCamera/Materials/M_Blue.uasset


Initial setup

This step is required if you added/migrated Strategy Camera into an existing project.

Setup GameMode

Open your project settings and navigate to Project - Maps & Modes. In the Default Modes section select BP_GameMode in the drop down menu for Default GameMode. If your project already has custom GameMode, set Default Pawn Class to BP_StrategyCamera and Player Controller Class to BP_PlayerController. If you already have custom classes set for above, or if you don't want to set BP_GameMode globally in project settings, perform this setup in your level instead. Navigate to World Settings tab and set GameMode Override in Game Mode section.

  

Setup input bindings

Open your project settings and navigate to Engine - Input. Setup the following input bindings:

Also make sure that Use Mouse for Touch is unchecked in Mouse Properties section.


Using Strategy Camera

To add Strategy Camera to your level, locate blueprint BP_StrategyCamera in the content browser and drag it into your level viewport. With BP_StrategyCamera object selected, navigate to Pawn section in Details window and set Auto Possess Player to Player 0. The camera is ready to use.

  

BP_StrategyCamera parameters

Strategy Camera blueprint parameters are provided under Player Camera group. Select BP_StrategyCamera object in the World Outliner and locate Player Camera parameter group in the Details window.

Movement Bounds Length-sets camera movement bounding box length. Given length is centered around BP_StrategyCamera object world position. Bounds are visualized with bounding box helper. Also affects MoveCamera function and prohibit camera target to move or teleport outside of specified bounds.
Movement Bounds Width-sets camera movement bounding box width. Given width is centered around BP_StrategyCamera object world position.
Offset Trace Zmax-sets start Z value for trace determining camera offset above terrain. This value is relative to BP_StrategyCamera object world position. Bounding box helper height visualizes the setting. Each time camera moves, a trace is performed from this point down to Offset Trace Zmin value. If specified Offset Trace Channel produces hit, camera target is repositioned along the Z axis to be at Offset value above hit point. If trace is unsuccessful, camera Z offset does not change.
Offset Trace Zmin-sets end Z value for trace determining camera offset above terrain. This value is relative to BP_StrategyCamera object world position.
Offset Trace Channel-sets trace channel for camera offset trace. To use a custom trace channel, set it up first in Project Settings - Engine - Collision - Trace Channels. By using custom trace channel you can control which objects should affect camera offset.
Offset-sets camera Z offset value above the point determined by offset trace hit. If you wish to debug offset functionality you can enable Visible flag for Target component in BP_StrategyCamera blueprint.
Initial X-sets initial X position of the camera. This value is relative to BP_StrategyCamera object world position.
Initial Y-sets initial Y position of the camera. This value is relative to BP_StrategyCamera object world position.
Initial Rotation-sets initial rotation of the camera (degrees)
Initial Distance-sets initial camera zoom distance
Min Distance-sets minimal camera zoom distance
Max Distance-sets maximal camera zoom distance
Angle-sets camera angle (degrees). This value is relative to the ground and has a range of 0 - 90 degrees.
Scroll Border Size-sets size of the scroll border area at window boundaries (pixels)
Movement Speed-sets camera movement speed at minimal distance (cm/s)
Max Movement Speed Multiplier-sets speed multiplier at maximal camera distance. Camera speed will gradually increase based on camera distance. Setting this to 1 effectively disables adaptive speed.
Rotation Speed-sets camera rotation speed (degrees/s)
Zoom Speed-sets camera zoom speed
Smoothing-sets camera smoothing coefficient. Lower values give more lag.

Optimization

Strategy Camera is implemented with all commonly required controls. Your particular project might not require all of them. For example, mouse LMB click and drag camera panning is commonly a must for RTS style game but is undesirable for TBS style game. Mobile builds need dedicated camera blueprint with all non-touch functionality stripped for performance considerations. Thus it is recommended to go into BP_StrategyCamera blueprint and tailor it to your project needs by disabling or removing all unneeded functionality.

Touch controls important note:
ProcessMouseWindowBorderScroll macro must be disabled if you are deploying on mobile device and intend to use touch controls. Mobile devices consider mouse locked to the top left corner of the screen in UE4 - this will cause mouse border scroll functionality to constantly activate and move your camera.

Below is the outline of modules used in BP_StrategyCamera blueprint Event Graph. Isolate blocks that you don't need and disable them by removing execution flow connections or simply delete them.

  

Keyboard/gamepad movement: block commented "Keyboard/gamepad movement control"
Keyboard/gamepad rotation: block commented "Keyboard/gamepad rotation control"
Keyboard/gamepad/mouse wheel zoom: block commented "Zoom control"
Mouse LMB click and drag movement: block commented "Mouse movement control and update"
Mouse RMB click and drag rotation: block commented "Mouse rotation control and update"
Mouse window border scroll: macro ProcessMouseWindowBorderScroll
Touch controls: block commented "Touch controls" and macro ProcessTouch

Camera functions

The following functions are implemented in the BP_StrategyCamera blueprint:

SetInputEnabled-enable/disable player input. Use this function call when you need to enable/disable player control over the camera.
MoveCamera-move camera to the specified location. Use this function call to move camera target to a new world location and optionally set new rotation and distance. If Teleport flag is set camera will move instantly. Otherwise it is advised to wait for camera until move is complete. While camera is performing the move, player input is disabled.
IsCameraMoving-returns true if camera is currently moving after MoveCamera call

Startegy Camera project comes with the sample level where you can find examples of the functions usage. BP_PlayerController contains MoveCamera example (activated by pressing '1') which shows camera move and "wait for camera" functionality. "Briefing" example (activated by pressing '2') shows chain of actions which block player input and move camera to the "objective" points. Two simple actor blueprints in the sample level (BP_Cone and BP_Cube) show examples on how to implement camera target move/teleport to object origin location on click/touch event.