(mochi) Line of Sight / Fog of War Package

To install:
Search for (mochi) Line of Sight Package in the community tab and install.

This package can be used to enable fog of war type behavior for both line of sight and pure range (package was created then updated to be general fog of war instead of just line of sight).

FogOfWarPlayerTemplate - this is the player template to spawn to enable fog of war behavior in the fog of war items
FogOfWarItemTemplate - template for an item that should have fog of war behavior
FogOfWarDetectorTemplate - template for an item that can act as an additional detector for the player(s)


  • FogOfWarPlayerScript
    • fogOfWarDetectors: initial list of detectors that the player should use in addition to the player entity
  • FogOfWarItemScript
    • itemHitPoints: array of locators used to determine if the item is in range, supply more for large items so that edges are detected or leave empty to just use the center of the item
    • childType: options are Children/Array, this determines which entities are hidden / shown when entering / exiting fog of war. Children means it will use the default children in the world tree (non-recursive atm). Array means will allow the option to set an array of entities that will be shown / hidden if only some portions of the entity should be shown / hidden.
  • FogOfWarDetectorScript
    • fogOfWarBehavior: options are LineOfSight/Range, this determines how items are determined as visible or not. LineOfSight needs a clear line of sight from a detection point to an item hit point and have the item within range as well. Range only needs to have the item within range to show.
    • fogOfWarTrigger: trigger that tracks entering / exiting of fog of war items (also used on initial local init to see which items are already within range on spawn)
    • fogOfWarRange: range that can be detected by this detector.
    • fogOfWarBuffer: distance that an item will stay visible even after leaving the fog of war range (to prevent flickering and smoother behavior of entering / exiting range).
    • rayCastCenterOffset: Vector offset for where to send raycasts off from (useful for players to have raycast send from head as well as anything where the entity origin is too close to the ground/terrain).
    • fogOfWarTrigger - this is the trigger that tracks as items enter/leave, should be a cube that has each side at least the size of the (detection range + buffer) * 2

Example of a player and a detector spotting some sneaky cheeses both using line of sight detection, player has a range of 1000, and detector has a range of 500 as denoted by the lights.