Enemy Masses RTS Controller
The Enemy Masses RTS Controller is the core component for player interaction in an RTS game built with Enemy Masses. It handles unit selection, movement commands, formations, and attack orders. It is designed to work seamlessly with the EnemyMassesCrowdController to manage thousands of units efficiently.

Features
Selection System:
Click Selection: Select individual units.
Double-Click Selection: Select all units of the same type/faction on screen.
Drag Selection: Classic RTS box selection for grouping units.
Additive Selection: Hold
Shiftto add units to the current selection.
Command System:
Move Commands: Right-click to move selected units to a destination.
Attack Commands: Right-click on an enemy unit to order an attack.
Formations: Units automatically arrange themselves in formations (e.g., Rectangle) at the destination.
Advanced Formation Control:
Drag-to-Adjust Spacing: Hold the command button and drag horizontally to adjust the spacing of the formation before issuing the move order.
Formation Rotation: Hold both command and selection buttons to rotate the formation facing direction.
Ghost Preview: Visualizes the formation shape and position before you commit to the move.
Faction Control: Restrict selection and commands to specific player-controlled factions.
Fog of War Integration: Automatically hides non-player units when they are not visible (requires a Fog of War provider).
Input System Support: Fully supports Unity's New Input System and the legacy Input Manager.
Getting Started
Create an empty GameObject or use your existing "GameController" object.
Add the
EnemyMassesRTSControllercomponent.Assign the Crowd Controller reference (if not automatically found).
Assign the Target Camera (usually your Main Camera).
(Optional) Assign the Minimap Controller to prevent accidental deselection when clicking on the minimap.
Key Settings
1. Selection Settings
Enable Click/Drag Selection: Toggles basic selection methods.
Double Click Time: How fast a double-click must be registered.
Agent Selection Mask: Layer mask to determine what objects can be selected.
2. Command Settings
Move Formation: The default shape units will take (currently supports
Rectangle).Formation Spacing: Default distance between units.
Enable Drag To Adjust Spacing: Allows players to dynamically change formation density.
Enable Rotation Adjustment: Allows players to set the facing direction of the formation.
3. Input Settings
The controller supports both input systems.
New Input System: You can rebind
Selection Button(Left Click),Command Button(Right Click), and modifiers directly in the Inspector.Legacy Input: Uses standard mouse button indices (0, 1, 2) and KeyCodes.
4. Visual Settings
Selection Rectangle: Customize the color and border of the drag box.
Move Indicator: Customize the visual marker that appears when a move command is issued.
Selection Highlight: Customize the ring or highlight that appears under selected units.
5. Group Bookmarks
Select your Agents. Hold the Control Group Save Modifier key and press the keys 0 to 9.
Press the Group key to select the Group
Double press your Group key to focus the camera on the selected group
Advanced Usage
Formation Dragging
This feature gives players precise control over unit positioning:
Select a group of units.
Hold Right-Click (Command Button) at the target location.
Drag Mouse Horizontally:
The "Ghost" markers will appear, showing where units will go.
Dragging expands or contracts the formation spacing.
Release Right-Click: The units will move to the previewed positions.
Formation Rotation
To face units in a specific direction:
Select units.
Hold Right-Click (Command Button).
Hold Left-Click (Selection Button) while holding Right-Click.
Drag Mouse: The formation rotates around its center.
Release: Units move and rotate to face the new direction.
Attack Targeting
Attack Target Mask: Ensure this includes the layers your enemy units are on.
Attack Target Click Radius: Since thousands of units might not have individual colliders for performance, this radius helps detect clicks "near" a unit to register an attack command.
Integration Tips
Fog of War: If you are using a Fog of War system, assign the provider to the
Fog Of War Providerfield. The controller will automatically cull (hide) units that should not be visible to the player.Minimap: Link the
RTSMinimapControllerto ensure that clicking on the UI map doesn't deselect your units in the world.
Last updated