Spatial Queries & AI Targeting
Issue: Severe FPS drops and micro-stutters during combat-heavy scenarios with multiple bots.
Root cause: Legacy O(N) spatial scanning over global entity collections, combined with per-frame allocations for query results.
Fix: Migrated spatial logic to Physics-based queries using non-alloc OverlapSphere calls and cached buffers.
Result: Eliminated combat-driven GC spikes and reduced peak script time from ~5-6 ms to ~1–2 ms.
Hidden GC Allocations in Core Loop
Issue: Frame spikes during movement and camera input under normal gameplay conditions.
Root cause: Implicit allocations in event dispatching and boxed value types in input pipeline.
Fix: Rewrote event system using strongly-typed non-alloc delegates and removed boxing in core update loops.
Result: Achieved near-zero GC allocation baseline during active gameplay.