Purpose

Demonstrates terrain map line-of-sight (LOS) system for BLUEFOR, OPFOR and CIV agents. 

How to Use

Allow the Razish terrain map to load in completely, then use the button commands in the upper region of the screen.

Points

  • Add Points, click the button once to enable (red highlight) then click two or more points on the map to the display the distance between them in meters. Click the buton again to toggle off the mode. 
  • Clear Points, click the button to remove any user-instanced points. 

Agents

  • LOSBlueAgent, click the button once to enable (yellow highlight) then click on the map to instance an agent. 
  • LOSRedAgent, click the button once to enable (yellow highlight) then click on the map to instance an agent. 
  • LOSCivAgent, click the button once to enable (yellow highlight) then click on the map to instance an agent. 
  • Drag-select single or multiple agents by left-click, and then direct agent(s) to a waypoint on the plane designated by right-click of the mouse. Agents will navigate around obstacles to reach a set waypoint and stop. Navigation of agents can be interrupted by another right-click of the mouse; agents will then navigate to that new waypoint location.

Agent LOS

  • Individual Blue/Red/Civ agents display a LOS radius corresponding to their respective color. This radius will appear obstructed by terrain and structural obstacles. 
  • Where instances of agent LOS radii overlap their colors will highlight.

Camera

  • Press WASD keys to move camera
  • Press QE keys to rotate camera
  • Hold Space bar to raise camera
  • Hold Ctrl to lower camera

Note, instanced agents cannot be removed currently; reload the scene to clear the map of agents.

Scene Location & Name

Assets/Ride/Examples/LOS/ExampleLOS.unity

Setup Requirements 

Multiple objects and prefabs are required by the LOS system in order to achieve the results in this example scene.

ExampleLOS Script

First, add this script to an object in your scene to enable the LOS system. 

Terrain-related Prefabs

Instance the following prefabs to enable loading of a navigable terrain map:

  • TerrainCameraLOS prefab – contains mask component for LOS system; replaces MainCamera
  • TerrainCenter object – sets default camera position relative to placement on map at run-time
  • TerrainLoader prefab – defines the terrain map for loading
  • TerrainNavLoader prefab – unit navigation of terrain
  • TerrainMeasureDistance prefab – Point measurement UI 
  • TerrainLOSAgentCreator prefab – Agent type UI
  • RazishNavMesh prefab – disable/hide this object by unchecking its box in the inspector

SelectorUI Prefab and RectSelectionDisplay Script

Next, import the SelectorUI prefab into your scene to enable rectangular selection and highlight of units by way of the RectSelectionDisplay script.

This prefab also contains the necessary EventSystem and Canvas child prefabs.

Scroll Up