LSFS: Non Essential Components

The Large Scale Combat System comes with several optional but powerful supporting systems designed to enhance performance and immersion. This section covers the setup and configuration of the Animator LOD and CameraController.


1.AnimatorLOD

To maintain high performance in battles with hundreds or thousands of units, it is essential to reduce the work the CPU has to do. The Animator LOD (Level of Detail) system automatically reduces the update frequency of animations for units that are far from the camera or outside the screen, using the high-performance C# Job System.

  • AnimatorLODSettings: A component that holds the global configuration for all LOD levels.
  • AnimatorLODManager: The scene-based manager that runs the calculations.
  • AnmatorLOD: A simple „tag“ component you add to your unit prefabs.

AnimatorLODSettings

This is the main configuration component. It should be placed on the same GameObject as the AnimatorLODManager.

  • mainCamera: The primary camera used for distance calculations. If left empty, it will default to Camera.main.
  • lodSettings: An array defining your LOD levels.
    • distance: The distance at which this LOD level becomes active.
    • updateEveryXFrames: How often the animator should update. 1 means every frame, 2 means every second frame, etc.
  • cullDistance: The absolute distance at which animators are effectively disabled.
  • disableSkinnedMeshRenderer: If checked, the unit’s mesh will be hidden entirely when it is off-screen or beyond the cullDistance. This provides a significant performance boost.
  • useLOD: A master switch to enable or disable the entire system.

Step 2: Addjust the AnimatorLOD settings on the Manager object in the Scene Prefab.

Step 3: Tag your Prefabs On your unit prefabs, add the AnimatorLOD component to the same GameObject that contains the Animator. It requires no further setup. The manager will automatically find and manage all active units with this component.

Please note that hundreds of Animators are very heave for the performance, even with AnimatorLOD. It is recommended to implement other animation solution such as GPU instancing, using the AnimatorLinkLODmanager


2. Camera Controller

The LSCS includes a flexible, professional-grade RTS-style camera. It’s designed to give the player smooth and intuitive control over the battlefield, with built-in features for panning, rotating, zooming, and staying within the map boundaries.

  • CameraController.cs: The all-in-one script that provides the complete camera logic. It should be placed on your main camera.

CameraController Component

This is the main configuration component for all camera behavior. Add it to your Main Camera GameObject.

Input Actions via Reference This section links the camera’s functions to your Unity Input System Asset.

  • moveActionReference: The 2D Vector action for panning the camera (e.g., WASD).
  • zoomActionReference: The 1D Axis action for zooming in and out (e.g., Mouse Scroll Wheel).
  • sprintActionReference: The Button action to increase pan speed (e.g., Left Shift).
  • rotateActionReference: The Button action that must be held to enable rotation (e.g., Middle Mouse Button).

Movement Settings

  • panSpeed: The base speed for camera movement.
  • sprintMultiplier: How much faster the camera moves when the sprint key is held (e.g., a value of 2 means 200% speed).
  • zoomSpeed: How quickly the camera zooms in and out.
  • rotationSpeed: The speed of horizontal (left/right) rotation.
  • pitchRotationSpeed: The speed of vertical (up/down) rotation.
  • minZoomHeight / maxZoomHeight: The closest and furthest the camera can zoom, measured in world units (Y-axis).

Pitch Rotation Settings

  • minPitch / maxPitch: The minimum and maximum vertical angle (in degrees) the camera can tilt to. 10 is almost top-down, 80 is a low, cinematic angle.

Smoothing Settings These values control the smoothness and inertia of the camera, preventing abrupt starts and stops. A lower value means a faster, more responsive camera, while a higher value results in a smoother, more cinematic feel.

  • panSmoothTime: Smoothing for WASD movement.
  • zoomSmoothTime: Smoothing for the scroll wheel zoom.
  • rotationSmoothTime: Smoothing for the camera rotation.

Ground Clipping Prevention This system prevents the camera from clipping into the terrain when zooming or moving over hills.

  • groundLayer: The physics layer your terrain or ground plane is on. The camera will use a raycast on this layer to detect the ground height.
  • minHeightAboveGround: The minimum distance the camera will always keep from the ground.

Cursor

  • lockCursor: If checked, confines the mouse cursor to the game window, which is common for RTS games.

World Boundaries This feature locks the camera within a defined playable area.

  • lockCamera: A master switch to enable or disable the boundary lock.
  • worldCorner1 / worldCorner2: Assign two empty Transform objects placed at the diagonal corners of your map. The script will draw a Gizmo in the Scene View to help you visualize this boundary.