Skip to content

VisionSource

The VisionSource component defines an area of vision that reveals fog of war in real-time. It tracks the GameObject's position and rotation from the transform, while allowing additional offsets and scale adjustments.

Rotation Behavior

The rotation behavior depends on the Orientation setting in the FogOfWarManager:

  • XZ orientation (top-down games): Uses the GameObject's Y-axis rotation
  • XY orientation (2D side-scrolling games): Uses the GameObject's Z-axis rotation

Usage

  1. Add the VisionSource component to any GameObject that should reveal fog.

  2. Configure the component properties in the Inspector.

Inspector Properties

VisionSource Inspector

  • Shape (enum): The geometric shape used for fog revelation.

    • Circle - Circular vision area
    • Square - Square vision area
  • Position Offset: Position offset relative to the GameObject's position.

  • Rotation Offset (0-360): Rotation offset in degrees added to the GameObject's transform rotation.

  • Scale (min 0): Size multiplier of the vision shape. Independent of the GameObject's transform scale.

Public API

  • VisionShape Shape - Gets or sets the geometric shape of the vision area (Circle or Square).

  • Vector2 PositionOffset - Gets or sets the position offset relative to the GameObject's position.

  • float RotationOffset - Gets or sets the rotation offset in degrees. Values are automatically normalized to the 0-360 range.

  • Vector2 Scale - Gets or sets the size multiplier. Minimum value is Vector2.zero (values below zero are clamped). Independent of the GameObject's transform scale.