# kaganxsahin/kagansduckhuntgame architecture

> Architecture diagram of the GitHub repository kaganxsahin/kagansduckhuntgame, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kaganxsahin/kagansduckhuntgame
- Repository: https://github.com/kaganxsahin/kagansduckhuntgame

## Overview

This is a Unity Duck Hunt game integrated with an Arduino light gun. The player pulls the physical trigger; Arduino sends the fire signal to Unity, which performs a brief black-frame/white-target detection sequence. Arduino reports the light-sensor result, enabling Unity to register a hit, while Arduino drives recoil feedback. The README documents these responsibilities and the script roles; source excerpts were unavailable, so links between individual Unity scripts are limited to documented relationships.

Main entry points: [`KagansDuckHuntGame/Assets/Scripts/GameController.cs`](https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/KagansDuckHuntGame/Assets/Scripts/GameController.cs) (Game Logic), [`DuckGun/DuckGun.ino`](https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/DuckGun/DuckGun.ino) (Gun Controller), [`KagansDuckHuntGame/Assets/Scripts/ComController.cs`](https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/KagansDuckHuntGame/Assets/Scripts/ComController.cs) (Serial Connection), [`KagansDuckHuntGame/Assets/Scripts/Duck.cs`](https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/KagansDuckHuntGame/Assets/Scripts/Duck.cs) (Duck Target)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_hardware["Light Gun Hardware"]
  node_trigger["Trigger Switch"]
  node_ldr["Light Sensor"]
  node_arduino["Gun Controller<br/>[DuckGun.ino]"]
  node_motor["Recoil Motor"]
end

subgraph group_integration["Serial Integration"]
  node_com["Serial Connection<br/>[ComController.cs]"]
end

subgraph group_game["Unity Game"]
  node_game["Game Logic<br/>[GameController.cs]"]
  node_scene["Game Scene<br/>[GameScene.unity]"]
  node_duck["Duck Target<br/>[Duck.cs]"]
  node_score["Score Feedback<br/>[ScoreObject.cs]"]
end

node_player(("Player"))
node_display["Game Display"]

node_player -->|"pulls"| node_trigger
node_arduino -->|"sends serial data"| node_com
node_com -->|"delivers signals"| node_game
node_game -->|"renders flash"| node_display
node_ldr -->|"reports light"| node_arduino
node_arduino -->|"activates recoil"| node_motor
node_game -.->|"validates target"| node_duck
node_game -.->|"updates feedback"| node_score

click node_arduino "https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/DuckGun/DuckGun.ino"
click node_com "https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/KagansDuckHuntGame/Assets/Scripts/ComController.cs"
click node_game "https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/KagansDuckHuntGame/Assets/Scripts/GameController.cs"
click node_scene "https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/KagansDuckHuntGame/Assets/Scenes/GameScene.unity"
click node_duck "https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/KagansDuckHuntGame/Assets/Scripts/Duck.cs"
click node_score "https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/KagansDuckHuntGame/Assets/Scripts/ScoreObject.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_trigger,node_ldr,node_arduino,node_motor toneBlue
class node_com toneAmber
class node_game,node_scene,node_duck,node_score toneMint
class node_player,node_display toneIndigo
```

## Components

### Light Gun Hardware

- **Trigger Switch**
- **Light Sensor**
- [Gun Controller](https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/DuckGun/DuckGun.ino): `DuckGun/DuckGun.ino`
- **Recoil Motor**

### Serial Integration

- [Serial Connection](https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/KagansDuckHuntGame/Assets/Scripts/ComController.cs): `KagansDuckHuntGame/Assets/Scripts/ComController.cs`

### Unity Game

- [Game Logic](https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/KagansDuckHuntGame/Assets/Scripts/GameController.cs): `KagansDuckHuntGame/Assets/Scripts/GameController.cs`
- [Game Scene](https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/KagansDuckHuntGame/Assets/Scenes/GameScene.unity): `KagansDuckHuntGame/Assets/Scenes/GameScene.unity`
- [Duck Target](https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/KagansDuckHuntGame/Assets/Scripts/Duck.cs): `KagansDuckHuntGame/Assets/Scripts/Duck.cs`
- [Score Feedback](https://github.com/kaganxsahin/kagansduckhuntgame/blob/main/KagansDuckHuntGame/Assets/Scripts/ScoreObject.cs): `KagansDuckHuntGame/Assets/Scripts/ScoreObject.cs`

### Other components

- **Player**
- **Game Display**

## Connections

- Player → Trigger Switch: pulls (evidence: `README.md`)
- Gun Controller → Serial Connection: sends serial data (evidence: `README.md`)
- Serial Connection → Game Logic: delivers signals (evidence: `README.md`)
- Game Logic → Game Display: renders flash (evidence: `README.md`)
- Light Sensor → Gun Controller: reports light (evidence: `README.md`)
- Gun Controller → Recoil Motor: activates recoil (evidence: `README.md`)
- Game Logic → Duck Target: validates target
- Game Logic → Score Feedback: updates feedback
