Overview
The Shark Guestbook is an interactive Unity simulation where fish generated from a Python pipeline are introduced into a dynamic ocean environment. AI-driven sharks, environmental cycles, and a raffle mode for special behaviors create a living ecosystem. This document outlines the technical structure, components, and runtime flow.
System Architecture
High-level interaction between major components:
+-------------------+ +----------------+ | TextureGenerator | ---> | FishMetadata | | (Python) | | (Data) | +-------------------+ +----------------+ | | v v +-----------------+ +------------------+ | PreySpawner | --> | FishAI.cs | +-----------------+ +------------------+ | v +-----------------+ +------------------+ | SharkAI.cs | --> | RaffleHungerMgr | +-----------------+ +------------------+ | v +-------------------+ | DayNightRotator | | WaterEnvironment | +-------------------+

Core Components
π FishAI.cs
Controls individual fish movement using spine-based animation. Implements wave motion, drag, and reactive steering. Fish are spawned with metadata (textures, IDs) generated externally.
π¦ SharkAI.cs
Governs shark behavior including roaming, prey detection, pursuit, and
βsuckβ routine for consuming fish. Sharks pivot and move relative to a
viewOrigin
transform, simulating realistic swimming arcs.
π£ PreySpawner.cs
Dynamically spawns fish and sharks at runtime.
Sharks are assigned their own viewOrigin
, while fish are
instantiated as standalone GameObjects.
π½οΈ RaffleHungerManager.cs
Introduces βraffle mode,β where sharks alter hunger levels and speed dynamics. Controls when sharks are in normal vs. event-driven states.

π DayNightRotator.cs
Handles lighting and directional rotation for a natural day/night cycle. Synchronizes environmental visuals for realism.
π WaterEnvironmentManager.cs
Manages HDRP water environment, visual effects, and integration with particle systems (e.g., glowing spores, ripples). Ensures sharks and fish interact believably with water surfaces.
π FishMetadata.cs
Stores structured data for fish including texture IDs, names, and
behavioral properties. Acts as the data layer connecting Pythonβs
TextureGenerator
to Unity.
Runtime Flow
- Textures and fish metadata are generated via TextureGenerator.py.
- PreySpawner reads metadata and spawns fish with unique appearances.
- FishAI controls swimming and flocking movement.
- SharkAI roams, detects prey, and engages feeding routines.
- RaffleHungerManager adjusts shark behavior during special modes.
- DayNightRotator updates environment lighting dynamically.
- WaterEnvironmentManager ensures visual and physical water realism.

Challenges & Solutions
- Ensuring sharks pivot around
viewOrigin
β fixed via transform smoothing. - Balancing fish swarm realism with performance β optimized
SmoothDamp
usage. - Synchronizing raffle mode with normal AI β centralized hunger manager.