## Devblog: Implementing the Scanner Attachment
![[scanner-image.png]]
The Scanner Attachment is a modular, rail-mounted device that provides localized enemy detection in real-time. Designed for tactical awareness in high-intensity scenarios, it integrates with the existing weapon and entity systems to generate a dynamic minimap overlay. From a development standpoint, this feature offered a clean opportunity to bridge world-space data with screen-space UI, while remaining performant and flexible enough for future upgrades.
---
### Functionality Overview
![[scanner-action.gif]]
The scanner can be mounted on the left or right side rail of any compatible primary weapon. Once the weapon is actively held, the scanner activates and begins periodically scanning for enemies within a defined radius. Detected enemies are visualized as red blips on a circular minimap embedded in the scanner’s physical housing.
The device is designed to deactivate when released, preventing unnecessary updates and keeping visual clutter to a minimum during combat transitions.
### Internal Mechanics
**Activation Logic**
The scanner listens for grab events via the weapon’s modular reference system. On grab, it sets itself active and enables the UI. On release, it disables the visual and functional components.
**Detection Cycle**
At a fixed refresh interval (default: 1 second), the scanner performs the following steps:
- Queries the `EntityManager` for all living entities on the `Enemy` team.
- Measures distance from the scanner’s world position to each valid entity.
- Stores qualifying positions for rendering on the minimap.
**Minimap UI Rendering**
Each enemy is represented by a 2D icon within a circular UI canvas rendered in world space. The system:
- Normalizes each detected enemy’s position relative to the scanner.
- Rotates the result based on the scanner’s forward direction to maintain orientation consistency.
- Projects the position onto the canvas using radial scaling, proportional to detection distance.
- Retrieves icon instances from a pooled prefab system to minimize allocation overhead.
To signal a refresh, a fading radial mask animates in sync with the scan using a tweened alpha value. This creates a subtle but readable pulse effect, simulating a radar sweep.
---
### System Integration
The scanner integrates directly with several existing systems:
- **Entity System**
Utilizes the entity system to quickly retrieve cached enemy positions.
- **Weapon Part System**
Functions as a detachable module via the part system. This enables compatibility with the part customization system, unlock system, and loadout system.
- **LED Screen UI Shader**
Leverages the physical screen shader used by other objects, which can display any camera or render texture as if it is a real LED screen.
---
### Design Intent and Gameplay Impact
The Scanner Attachment is particularly effective in scenarios with multiple entry points, low visibility, or when defending fixed objectives. In missions with verticality or branching tunnels, the scanner helps reduce ambiguity and enables more deliberate positioning.
In wave defense contracts, for instance, players are often overwhelmed by multi-directional enemy flows. The scanner provides an edge—early warnings, directional awareness, and confirmation of cleared zones without requiring line-of-sight.
Because the minimap operates independently of vision or audio cues, it becomes a key tool for players who prefer a more methodical or support-focused role. It also encourages group coordination, as players can relay radar contacts to teammates who may be unaware of nearby threats.
The scanner started as a utility tool, but its gameplay implications became immediately clear during internal playtests. It subtly shifts how players approach navigation, timing, and group strategy without overpowering the core combat loop. It’s a lightweight, responsive layer of tactical feedback that slots naturally into the flow of play.