|
| 1 | +# 🧠 Vision Field System for Unity |
1 | 2 |
|
| 3 | +## 🔍 Overview |
| 4 | + |
| 5 | +**VisionFieldSystem** — модульная и гибкая система обзора (FOV) для Unity, включающая визуализацию зоны видимости и обнаружение целей с учётом препятствий. Поддерживает разные формы обзора и настраивается через инспектор. |
| 6 | + |
| 7 | +Подходит для врагов, турелей, NPC, охранников и любых AI-систем восприятия. |
| 8 | + |
| 9 | + |
| 10 | +## 📽️ Demo Preview |
| 11 | + |
| 12 | +| Type | Mesh + Detector Pair | Preview | |
| 13 | +|------------------|--------------------------------------------------------|--------------------------------------------------------| |
| 14 | +| **Circle** | `VisionFieldMesh` + `TargetFieldDetector` |  | |
| 15 | +| **Arrow** | `VisionArrowMesh` + `TargetArrowDetector` |  | |
| 16 | +| **Half Ellipse** | `VisionHalfEllipseMesh` + `TargetHalfEllipseDetector` |  | |
| 17 | +| **Triangle** | `VisionOffsetTriangleMesh` + `TargetOffsetTriangleDetector` |  | |
| 18 | +| **Square** | `VisionSquareMesh` + `TargetSquareDetector` |  | |
| 19 | +| **Rhombus** | `VisionRhombusMesh` + `TargetRhombusDetector` |  | |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +https://github.com/user-attachments/assets/c0864105-69f8-498b-9de5-39c403db2e54 |
| 24 | + |
| 25 | +https://github.com/user-attachments/assets/3f6d499e-c2e4-4b62-b511-3e272ae8206d |
| 26 | + |
| 27 | +https://github.com/user-attachments/assets/8ce44c5d-a9ee-48d7-9dfa-58d729b61d30 |
| 28 | + |
| 29 | +## ⚙️ Features |
| 30 | + |
| 31 | +- 🧩 Visual FOV using procedural mesh |
| 32 | +- 🎯 Raycast-based target detection with obstacle mask |
| 33 | +- 🧪 Debug Gizmos for ray tracing and hit visualization |
| 34 | +- 🛠️ Fully customizable parameters (width, height, segments, tilt, offset) |
| 35 | +- 🎥 Runtime detection events: `OnTargetDetected`, `OnTargetLost` |
| 36 | +- 🌗 `RaycastOffset` to avoid surface clipping |
| 37 | +- ♻️ Clean modular architecture: easy to extend |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## 🧰 How to Use |
| 42 | + |
| 43 | +1. Add a **Vision Mesh** component (e.g. `VisionFieldMesh`) to a GameObject. |
| 44 | +2. Attach the corresponding **Target Detector** (e.g. `TargetFieldDetector`). |
| 45 | +3. Set required masks and dimensions in the inspector. |
| 46 | +4. Enable **Is Show Debug** to see rays and hit points in the Scene. |
| 47 | +5. Subscribe to target events: |
| 48 | + |
| 49 | +```csharp |
| 50 | +_detector.OnTargetDetected += enemy => Debug.Log($"🎯 Seen: {enemy.name}"); |
| 51 | +_detector.OnTargetLost += enemy => Debug.Log($"👀 Lost: {enemy.name}"); |
| 52 | +🗂️ Project Structure |
| 53 | +bash |
| 54 | +Копировать |
| 55 | +Редактировать |
| 56 | +Assets/ |
| 57 | +└── Code/ |
| 58 | + ├── Cameras/ |
| 59 | + ├── Editors/ |
| 60 | + ├── Enemies/ |
| 61 | + ├── Infrastructure/ |
| 62 | + ├── Levels/ |
| 63 | + ├── Players/ |
| 64 | + ├── UI/ |
| 65 | + ├── Utilities/ |
| 66 | + ├── Weapon/ |
| 67 | + └── VisionCone/ |
| 68 | + ├── Detectors/ |
| 69 | + ├── Factory/ |
| 70 | + ├── Provider/ |
| 71 | + └── Visions/ |
| 72 | +``` |
| 73 | + |
| 74 | +✅ Requirements |
| 75 | +Unity 2021.3+ |
| 76 | +URP or Built-in RP |
| 77 | +DOTween (optional, for demo animations) |
0 commit comments