
Part 7 – RTS Camera Edge Scrolling – Smooth Mouse Movement
Add edge scrolling to your RTS camera in Unreal Engine 5 with Game + UI mode, cursor lock, and smooth screen-edge movement using Blueprints.
Part 7 – RTS Camera Edge Scrolling – Smooth Mouse Movement
Welcome back to the RTS Camera Series! In this chapter, we’ll add one of the most classic RTS mechanics: mouse edge scrolling. When the cursor touches the top, bottom, left, or right of the screen, the camera smoothly moves across the map. To make it work properly, we’ll first configure our project to Game + UI mode so the mouse cursor behaves correctly—locked inside the viewport and always visible.
By the end, you’ll have both cursor support and edge scrolling movement fully integrated into your RTS camera system.
Step 1 – Game + UI Mode & Cursor Setup
- Open BP_RTSPlayer.
- Add an Event Begin Play node.
- From it, add a Sequence node (keeps logic tidy).
- Get Player Controller.
- Connect it to Set Input Mode Game and UI:
- In Mouse Lock Mode → Lock Always
- Hide Cursor During Capture → Unchecked
- From the same Player Controller, add Set Show Mouse Cursor → true.
➡️ Test now: when you press Play, the cursor stays visible and locked inside the game window. Press Escape to stop.
Step 2 – Grab Mouse Position & Viewport Size
- Right-click in BP_RTSPlayer → Get Player Controller.
- From it, add Get Mouse Position (returns Location X, Y).
- Also add Get Viewport Size (split values into X, Y).
- Divide:
MouseX / ViewportSizeX
MouseY / ViewportSizeY
These normalized values (0–1) are what we’ll check against screen edges.
Step 3 – Edge Detection Logic
We’ll compare normalized values against thresholds:
- Greater than 0.98 → at screen edge.
- Less than 0.02 → at opposite edge.
This works for both axes (X for horizontal, Y for vertical).
Step 4 – Reuse Movement Functions
Earlier in the series, we set up WASD camera movement with Add Movement Input. Collapse those nodes into reusable functions:
- MoveForward (using forward vector)
- MoveRight (using right vector)
This avoids duplication and keeps the blueprint modular.
Step 5 – Connect to Movement
-
For X division (horizontal):
-
0.98 → call MoveRight scale
+1
- <0.02 → call MoveRight scale
-1
-
-
For Y division (vertical):
-
0.98 → call MoveForward scale
-1
- <0.02 → call MoveForward scale
+1
-
Compile and save.
Step 6 – Test & Adjust
Play the level and move your mouse to each edge. The camera should scroll smoothly.
Fine-tuning:
- Use 0.97 / 0.03 if you want a thicker edge detection zone.
- Adjust movement speed for comfort.
Final Result
✅ Mouse cursor locked in the game window
✅ Smooth camera movement when cursor hits screen edges
✅ Reusable functions for clean blueprints
This setup mirrors the polished feel of professional RTS titles.
What’s Next
In the next tutorial, we’ll expand camera controls with more advanced input mechanics and refine overall UX. Stay tuned!