Part 7 – RTS Camera Edge Scrolling – Smooth Mouse Movement

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

  1. Open BP_RTSPlayer.
  2. Add an Event Begin Play node.
  3. From it, add a Sequence node (keeps logic tidy).
  4. Get Player Controller.
  5. Connect it to Set Input Mode Game and UI:
    • In Mouse Lock ModeLock Always
    • Hide Cursor During CaptureUnchecked
  6. From the same Player Controller, add Set Show Mouse Cursortrue.

➡️ 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

  1. Right-click in BP_RTSPlayer → Get Player Controller.
  2. From it, add Get Mouse Position (returns Location X, Y).
  3. Also add Get Viewport Size (split values into X, Y).
  4. 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:

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:

This avoids duplication and keeps the blueprint modular.


Step 5 – Connect to Movement

Compile and save.


Step 6 – Test & Adjust

Play the level and move your mouse to each edge. The camera should scroll smoothly.

Fine-tuning:


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!


Resources


Code