cameraCamera System

RTS Camera Controller

The RTSCameraController is a fully-featured camera system designed for Real-Time Strategy (RTS) and similar top-down games. It provides smooth, intuitive controls that mimic classic RTS titles while also supporting modern gameplay styles like third-person action RPGs.

Overview

The camera controller is built around the concept of a pivot point on the ground. The camera orbits around this point at a configurable distance (zoom), pitch, and yaw angle. This design provides natural-feeling controls where:

  • Movement translates the pivot point across the world

  • Zoom moves the camera closer to or further from the pivot

  • Rotation orbits the camera around the pivot

circle-info

The RTSCameraController uses Unity's New Input System for all input handling. Ensure you have the Input System package installed and set as the Active Input Handling in Project Settings.


Adding the Camera Controller

Using the Setup Wizard

The easiest way to add the camera controller is through the Setup Wizard:

  1. Go to Tools > Enemy Masses > Setup Wizard

  2. Complete the wizard steps for the RTS Type Enemy Crowd

  3. The wizard automatically adds RTSCameraController to your Main Camera

Manual Setup

To add the controller manually:

  1. Select your Main Camera in the Hierarchy

  2. Add the RTSCameraController component

  3. Also add GPUICamera (required for GPU Instancer Pro rendering)

  4. Configure the settings in the Inspector


Camera Presets

Camera presets are ScriptableObject assets that store all camera configuration settings. This allows you to:

  • Create different camera styles for different game modes

  • Switch between presets at runtime (e.g., tactical view vs. cinematic view)

  • Share camera configurations across projects

Built-in Presets

Enemy Masses includes several pre-configured presets:

Preset
Description
Best For

Classic RTS

Edge pan, middle-mouse drag, scroll zoom. No rotation.

StarCraft, Age of Empires

Modern RTS

WASD movement, middle-mouse rotation, zoom-to-cursor

Company of Heroes

Total War

Edge pan, right-drag pan, middle-drag rotation

Total War series

Supreme Commander

Edge pan, middle-drag pan, right-drag rotation

Supreme Commander

Third Person

Follow target, right-mouse rotation, collision avoidance

Action RPGs, Diablo-style

Creating a Custom Preset

  1. Right-click in the Project window

  2. Select Create > Enemy Masses > Camera Preset

  3. Configure the preset settings in the Inspector

  4. Assign to the camera controller's Camera Presets list

Selecting the Default Preset

When you have multiple presets in the Camera Presets list, you must specify which preset is active by default.

For example, if your preset list contains:

  • 0: Classic RTS

  • 1: Modern RTS

  • 2: Third Person

Set Active Preset Index to 2 to start with the Third Person preset.

circle-info

The camera automatically applies the active preset on Awake(). You can switch presets at runtime using TransitionToPreset().


Movement Controls

Edge Panning

Move the camera by positioning your mouse cursor at the screen edges.

Setting
Description
Default

Enable Edge Pan

Toggle edge panning on/off

true

Edge Pan Border

Pixel distance from edge to trigger (1-50)

10

Edge Pan Speed Multiplier

Speed modifier for edge panning

1.0

Disable Edge Pan Outside Window

Stop panning when cursor leaves game window

true

Keyboard Movement (WASD)

Standard keyboard-based camera movement.

Setting
Description
Default

Enable Keyboard Pan

Toggle WASD/Arrow movement

true

Move Speed

Base movement speed

20

Fast Move Speed

Speed when holding Shift

40

Move Acceleration

How quickly camera reaches target speed

8

Move Deceleration

How quickly camera stops

12

Smooth Movement

Enable smooth acceleration/deceleration

true

Default Key Bindings:

  • W / - Forward

  • S / - Backward

  • A / - Left

  • D / - Right

  • Left Shift - Sprint (fast move)

Drag Panning

Hold a mouse button and drag to pan the camera (like dragging a map).

Setting
Description
Default

Enable Drag Pan

Toggle drag panning

true

Drag Pan Button

Mouse button (Left/Middle/Right)

Middle

Invert Drag Pan

Reverse drag direction

false

Drag Pan Sensitivity

Movement sensitivity (0.1-5.0)

1.0


Zoom Controls

Control the camera's distance from the pivot point using the scroll wheel.

Setting
Description
Default

Enable Zoom

Toggle zoom functionality

true

Zoom Speed

Scroll wheel sensitivity

10

Min Zoom Distance

Closest camera distance

5

Max Zoom Distance

Furthest camera distance

100

Smooth Zoom

Enable smooth zoom interpolation

true

Zoom Smooth Speed

Interpolation speed

8

Zoom To Cursor

Zoom towards mouse position (Google Maps style)

true

circle-check

Rotation Controls

Rotate and tilt the camera to view the battlefield from different angles.

Setting
Description
Default

Enable Rotation

Toggle rotation controls

true

Rotation Button

Mouse button to hold for rotation

Right

Rotation Speed

Mouse sensitivity for rotation

1.0

Rotate Without Button

Always rotate with mouse movement

false

Enable Tilt

Allow vertical camera tilt (pitch)

true

Min Tilt Angle

Minimum pitch angle (°)

30

Max Tilt Angle

Maximum pitch angle (°)

80

Smooth Rotation

Enable smooth rotation interpolation

true

Rotation Smooth Speed

Interpolation speed

10


Camera Bounds

Restrict camera movement to a defined area (useful for keeping players within map boundaries).

Setting
Description
Default

Enable Bounds

Toggle movement boundaries

true

Min X / Max X

Horizontal (X-axis) boundaries

-100 / 100

Min Z / Max Z

Vertical (Z-axis) boundaries

-100 / 100

Bounds Mesh Renderer

Optional: Auto-set bounds from a mesh's AABB

null

circle-info

Assign a Bounds Mesh Renderer to automatically calculate camera bounds from a plane or terrain mesh. This is especially useful when your map size changes during development.


Camera Bookmarks

Save and recall camera positions quickly using keyboard shortcuts—essential for competitive RTS gameplay.

Setting
Description
Default

Enable Bookmarks

Toggle bookmark system

true

Bookmark Slots

Number of available slots (1-9)

4

Smooth Bookmark Transition

Animate when recalling bookmarks

true

Bookmark Transition Speed

Animation speed

5

Default Controls:

  • Alt + 1-9 - Save current camera position to bookmark slot

  • 1-9 - Recall saved bookmark position

Using Bookmarks via Script


Follow Mode (Third Person)

The camera can follow a target transform, useful for third-person gameplay or following selected units.

Setting
Description
Default

Follow Target

Transform to follow

null

Follow Mode

Enable/disable following

false

Follow Smoothness

How quickly camera catches up

5

Follow Target Offset

Offset from target position

(0, 0, 0)

Follow Offset In Target Space

Apply offset in target's local space

false

Follow Use Target Height

Use target's Y position for pivot height

false

Follow Target Height Offset

Vertical offset when using target height

1.5

Look-Ahead Settings

For smoother following of moving targets:

Setting
Description
Default

Enable Lookahead

Predict and lead target movement

false

Lookahead Time

Seconds to project ahead

0.2

Lookahead Smooth Time

Smoothing for lookahead changes

0.15

Max Lookahead Distance

Maximum lookahead offset

3

Starting/Stopping Follow Mode


Camera Collision

Prevent the camera from clipping through walls and terrain—essential for third-person gameplay.

Setting
Description
Default

Enable Camera Collision

Toggle collision avoidance

false

Camera Collision Layers

Layer mask for collision detection

Everything

Camera Collision Radius

Size of collision probe sphere

0.25

Camera Collision Buffer

Extra distance from surfaces

0.1

Camera Collision Ignore Triggers

Skip trigger colliders

true

Line of Sight Ground Repositioning

For cameras with negative pitch (looking upward):

Setting
Description
Default

Enable Line Of Sight Ground Reposition

Move camera along line-of-sight when blocked

false

Line Of Sight Ground Buffer

Extra distance from ground

0.1


Terrain Following

Keep the camera at a consistent height above the terrain.

Setting
Description
Default

Terrain Following

Toggle terrain height tracking

false

Height Above Ground

Target height above terrain

0

Ground Layer

Layer mask for ground detection

Everything


Preset Transitions

Smoothly animate between different camera presets at runtime.

Setting
Description
Default

Enable Preset Transitions

Toggle smooth transitions

true

Preset Transition Duration

Animation duration (seconds)

0.6

Preset Transition Curve

Animation easing curve

EaseInOut

Transitioning Between Presets


Integration with Other Systems

Game Creator 2 Integration

When using Game Creator 2 alongside the RTS Camera Controller, you typically want Game Creator's camera system to handle the camera initially (e.g., during menus, cutscenes, or third-person gameplay), then transition to RTS controls when needed.

Recommended Setup:

  1. On the RTSCameraController, disable Control Active On Start

  2. Use Game Creator 2's camera system as your primary camera

  3. When you want to switch to RTS controls, call SetControlActive(true) via a Game Creator Action or script

| Setting | Description | Default | |---------|-------------|---------|| | Control Active On Start | Whether the camera controller processes input immediately | true |

circle-exclamation

Example: Switching from Game Creator to RTS Camera

Disabling Camera Control

When using cutscenes, other camera systems, or UI dialogs, you may need to temporarily disable the camera controller:

Syncing with External Cameras

If another system moves the camera (e.g., Game Creator 2, Cinemachine), sync the controller when returning:

Suppressing Zoom Input

Prevent scroll wheel conflicts with other systems (e.g., formation cycling):


Public API Reference

Position & Movement

Zoom

Rotation

Bounds

Effects

Enable/Disable Controls


Events

Subscribe to camera events for integration with other systems:


Advanced Settings

Unscaled Time

Setting
Description
Default

Use Unscaled Time

Camera works during Time.timeScale = 0

true

This allows camera movement even when the game is paused.

Initial Setup

Configure the camera's starting state:

Setting
Description
Default

Initial Zoom

Starting camera distance

20

Initial Pitch

Starting vertical angle

45

Initial Yaw

Starting horizontal angle

0


Troubleshooting

Camera Not Moving

  1. Ensure Control Active On Start is enabled

  2. Check that the relevant movement options are enabled (Enable Edge Pan, Enable Keyboard Pan, etc.)

  3. Verify Input System is properly configured

Camera Clipping Through Geometry

  1. Enable Enable Camera Collision

  2. Set Camera Collision Layers to include your wall/terrain layers

  3. Increase Camera Collision Radius if camera still clips

Zoom Conflicts with Formation Cycling

The RTS Controller uses scroll wheel for formation cycling. Use SuppressZoom() or the built-in integration handles this automatically.

Jerky Movement During Rotation

  1. Enable Smooth Movement and Smooth Rotation

  2. Increase Rotation Smooth Speed

  3. Ensure frame rate is stable


Best Practices

  1. Use Presets: Create ScriptableObject presets rather than configuring in-scene for reusability

  2. Tune Bounds Early: Set up camera bounds that match your playable area

  3. Test at Different Zooms: Ensure edge panning and drag panning feel good at both close and far zoom levels

  4. Consider Follow Mode: For Action RPG hybrids, use the Third Person preset with collision enabled

  5. Save Performance: Disable unused features (e.g., terrain following if you have flat terrain)


  • EnemyMassesRTSController - Unit selection and commands

  • RTSMinimapController - Minimap rendering

  • FogOfWarLite - Visibility system

Last updated