Low-Allocation Event Bus (EventHub)
A thread-safe, copy-on-write event broker managing runtime domain events with O(1) lock-free dispatching and main-thread task marshaling.
Engineering Case Study
A Unity 6 runtime integration connecting Conversational AI, real-time embodiment, and autonomous gameplay actions.
Role
Gameplay / AI Programmer
Project Status
Technical Integration Prototype
Technical Focus
Runtime Integration, Multi-Modal AI, NPC Embodiment, Gameplay Actions
Section 01

Section 02

Section 03
This project was built to integrate a production-ready Conversational AI SDK into Unity 6, transforming static NPCs into responsive, real-time conversational agents. The goal was to bridge cloud-based multi-modal AI with interactive 3D gameplay without sacrificing frame budgets or game feel.
My work focused on engineering the core runtime integration and event pipeline: managing low-latency WebRTC audio streaming, synchronizing multi-modal embodiment including viseme lip-sync, gaze, and facial emotions, and routing autonomous gameplay action commands directly into Unity gameplay systems.
Section 04
The core challenge was coordinating high-frequency streaming network data with Unity's frame loop while maintaining strict performance budgets, zero-allocation memory constraints, and deterministic gameplay states.
Create a zero-allocation event dispatching pipeline to eliminate garbage collection spikes during continuous audio streaming.
Synchronize streaming TTS network audio with facial viseme blendshapes within a strict sub-300ms latency window.
Build a decoupled action execution pattern allowing generative AI to autonomously drive NavMesh movement, gaze, and animations.
Resolve conversational focus across multiple simultaneous NPCs without dialogue flickering or abrupt interruptions.
Section 05
The architecture follows strict Domain-Driven Design principles, cleanly decoupling low-level network streaming from high-level gameplay entities through an abstract domain event bus.
A thread-safe, copy-on-write event broker managing runtime domain events with O(1) lock-free dispatching and main-thread task marshaling.
Integrates native LiveKit WebRTC streaming, microphone capture, hardware audio resampling, and bidirectional Opus channels.
Drives real-time facial blendshapes for lip-sync visemes, three-dimensional emotion values across valence, arousal, and dominance, and procedural eye gaze.
An extensible command executor supporting 21+ gameplay archetypes including NavMesh locomotion, gestures, object observation, and UnityEvents.
Section 06
Conceptual conversational lifecycle based on the runtime integration and gameplay pipeline implemented for this system. It shows how voice input becomes synchronized NPC embodiment and gameplay action execution.
Microphone capture receives the player's conversational input in Unity.
LiveKit carries bidirectional audio through the real-time transport layer.
EventHub routes streaming and conversation events between runtime systems.
The Conversational AI runtime produces speech, emotion, and gameplay action data.
Audio timing anchors visemes while gaze and facial emotion update the character presentation.
The action dispatcher invokes typed gameplay commands such as movement, gestures, and observation.
Unity gameplay state and player context feed back into the next conversational interaction.
Section 07
I developed the runtime integration and gameplay systems required to make autonomous conversational agents responsive, performant, and extensible.
Implemented a low-allocation EventHub utilizing immutable subscriber arrays and weak-reference pruning, achieving zero runtime GC pressure during speech.
Configured native LiveKit FFI streaming and tied blendshape viseme evaluation directly to AudioSource.timeSamples to eliminate audio-lip desynchronization.
Authored the IConvaiActionExecutor command architecture with typed parameters and strict lifecycle completion guarantees covering success, failure reasons, and timeouts.
Engineered gaze-cone angle checks, proximity thresholds, and hold delays through switchDelaySeconds to reliably arbitrate player focus in multi-NPC scenes.
Section 09
View other projects or get in touch.