Renvix Assets

Overview

Vision Fog computes what each observer in your game can see, exactly, around every wall corner. On top of that it gives you vision cones, fog of war, objects that hide in the fog, and stealth AI that notices the player gradually. It works in top-down 2D, 3D and 2D isometric games.

How it works

Everything starts with a Vision Source. It is the eyes of a player, a guard or a security camera. Every update it computes the area visible from its position: a polygon clipped by the colliders around it.

Other components read this one result:

  • Vision Cone Renderer draws it, so the player sees where a guard is looking.
  • Fog Of War clears the fog wherever a source of its team sees.
  • Fog Hider hides an object while no source of a team sees it.
  • Vision Perception checks which Vision Targets are inside it and turns that into awareness: unaware, suspicious, alerted.

Because the cone, the fog, the hidden objects and the AI all use the same visible area, they always agree. If the player sees a guard's cone touching him, the guard sees him too.

Components

ComponentAdd it toWhat it does
Vision SourceAnything that sees: player, guard, cameraComputes the visible area
Vision Cone RendererThe source or a child of itDraws the visible area, colored by awareness
Vision PerceptionAn object with a Vision SourceAwareness meter per target, events, memory of the last seen position
Detection Profile (asset)Shared by observers of one kindDetection speed, awareness levels and memory
Vision TargetPlayer, NPCs, anything that can be noticedHow noticeable it is, which points of it can be seen
Vision OccluderA single obstacleMakes it fully or partly see-through
Fog Of WarAn empty object, one per teamDraws the fog and remembers explored areas
Fog HiderEnemies, items, buildingsHides the object while the team does not see it
Vision Fog Renderer FeatureYour URP renderer assetDraws the fog; needed for the Blur style and fog on 3D geometry

All components are in Add Component > Vision Fog. Detection Profiles are created with Assets > Create > Vision Fog > Detection Profile.

Key terms

Mode. Every source and fog works in one of three modes, chosen with the tabs at the top of the Inspector:

  • 2D: the XY plane and 2D physics.
  • 3D: the XZ ground and 3D physics. Obstacles are cut at the height of the source, its eyes.
  • 2D Isometric: sprites and 2D colliders in XY, but distances and angles are measured on the ground.

Obstacles. Any collider on the layers a source is blocked by. No extra component is needed on walls. Tilemap and Composite colliders work too.

Team. A number that connects sources to fogs and hiders. A source reveals the fog and the hidden objects of its own team only. Names for the teams are set in Project Settings > Vision Fog Teams.

Awareness. How much an observer knows about a target, from 0 to 1. It rises while the target is visible and falls after it is gone. Crossing the levels raises the events.