Skip to content

VisionFieldMesh was created as a versatile, editor-friendly tool to help developers prototype and implement enemy vision and detection logic quickly.

License

Notifications You must be signed in to change notification settings

SinlessDevil/VisionFieldMesh

Repository files navigation

🧠 Vision Field System for Unity

VisionFieldSystem — is a modular and flexible field of view (FOV) system for Unity that combines visual cone rendering with target detection, taking obstacles into account. It supports various vision shapes and is fully configurable through the Inspector.

Perfect for enemies, turrets, NPCs, guards, and any AI perception systems.

Watch the demo

Watch on YouTube

📽️ Demo Preview

Type Mesh + Detector Pair Preview
Circle VisionFieldMesh + TargetFieldDetector
Arrow VisionArrowMesh + TargetArrowDetector
Half Ellipse VisionHalfEllipseMesh + TargetHalfEllipseDetector
Triangle VisionOffsetTriangleMesh + TargetOffsetTriangleDetector
Square VisionSquareMesh + TargetSquareDetector
Rhombus VisionRhombusMesh + TargetRhombusDetector

📽️ Demo Videos

1.3.mp4
1.2.mp4
1.1.mp4

⚙️ Features

  • 🧩 Visual FOV using procedural mesh
  • 🎯 Raycast-based target detection with obstacle mask
  • 🧪 Debug Gizmos for ray tracing and hit visualization
  • 🛠️ Fully customizable parameters (width, height, segments, tilt, offset)
  • 🎥 Runtime detection events: OnTargetDetected, OnTargetLost
  • 🌗 RaycastOffset to avoid surface clipping
  • ♻️ Clean modular architecture: easy to extend

🧰 How to Use

  1. Add a Vision Mesh component (e.g. VisionFieldMesh) to a GameObject.
  2. Attach the corresponding Target Detector (e.g. TargetFieldDetector).
  3. Set required masks and dimensions in the inspector.
  4. Enable Is Show Debug to see rays and hit points in the Scene.
  5. Subscribe to target events:
🗂️ Project Structure
bash
Assets/
└── Code/
    ├── Cameras/
    ├── Editors/
    ├── Enemies/
    ├── Infrastructure/
    ├── Levels/
    ├── Players/
    ├── UI/
    ├── Utilities/
    ├── Weapon/
    └── VisionCone/
        ├── Detectors/
        ├── Factory/
        ├── Provider/
        └── Visions/
_detector.OnTargetDetected += enemy => Debug.Log($"🎯 Seen: {enemy.name}");
_detector.OnTargetLost += enemy => Debug.Log($"👀 Lost: {enemy.name}");

✅ Requirements

  • Unity 2021.3+
  • URP or Built-in RP
  • DOTween (optional, for demo animations)

About

VisionFieldMesh was created as a versatile, editor-friendly tool to help developers prototype and implement enemy vision and detection logic quickly.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published