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 (transform.position) but operates independently of the GameObject's rotation and scale.

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
  • Offset: The position offset of the vision shape relative to the GameObject's position.

  • Rotation (0-360): The rotation angle of the vision shape in degrees. This value is independent of the GameObject's transform rotation.

  • Scale (min 0): The size multiplier of the vision shape. This value is independent of the GameObject's transform scale.

Public API

  • Vector3 Position - Returns the current world position of the vision source (read-only). Retrieves the GameObject's transform.position.

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

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

  • float Rotation - Gets or sets the rotation angle in degrees. Values are automatically normalized to the 0-360 range. This value is independent of the GameObject's transform rotation.

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