Add RTS camera Panning

Enhanced TopDown template



To enchance default control, add cam rotation with R click and drag; WASD movement, and zoom in out to change cam zoom

Open Top Down project

For TopDownCharcter BP (zoom on mouse scroll),

event graph:
Add varaibles and make graph:
image.png
Add new variable:
image.png
image.png
Continuefalse Branch, duplicate ending nodes paste there
Command on the BP
image.png
Add event tick, drag Spring arm component and use it to create set and get target arm length nodes
(should be FInterp to, no constant, speed 2)
image.png
Add new variable
image.png
Go to viewport, change spring arm rotation Y from -50 to -40;
target arm length to 1650
image.png
Back to event graph, change default spring arm length default value to 1650
image.png
continue the event tick graph
image.png
Set Camera Zoom difference value 500, Camera Position Int value 0 (play around these 2 values to give different zoom effect)

P.S. Don’t know yet how to set zoom in/out limit

For TopDownController BP (rotate cam on R click and drag):


Add the following Axis movement in Project setting, Input
image.png
Open the BP even graph, start by creating input axis lock yew and pitch nodes:
image.png
Promote variable form the multiphy node above, name as Camera rotation multiplier, set default value as 3
image.png
Add comment for whole nodes created as:
On look right/left and look up/down, check if right mouse is held down and if yes, then world rotation added for side rotation, while local rotation is added for vertical movement so that it does not switch directions once rotated horizontally past each quarter of a circle (90 degrees)
image.png
Change camera rotation multiplier default value to change the speed of rotation
Test the game if hold R click mouse can rotate the map

Moving with Keypad WASD:


Keep adding more Input for WASD keyboard movement (set minus sacle for S and A):
image.png
back to event graph, add new button BP
command as below
(for cast to BP topdowncharacter node, R click and choose conver to pure cast)
image.png
image.png


Add camera rotation limit/constraint:


Continue the graph “On look right/left....90 degrees” one by adding:
image.png
the clamp float node min (high angle, minus value) and max (low angle, plus value) value determine how much angle can be rotated to top and bottom

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.