CASE STUDY WHIZBY
A short breakdown of a third-party code study. The case covers a limitation I found, the change I made, and the result.
Case 01 | Bullet WhizBys
LyraGame Facing-Aware WhizBy Direction
The Limitation
A whizby is the crack of a bullet passing the player. The stock implementation finds the closest point on the bullet's path to the listener, then decides which way the whoosh should sweep by comparing the firing vector's right vector against the path-to-listener perpendicular. Since this implementation is in world space, it only factors which side of the trajectory the listener stands on, but not which way the they are facing. Facing the shooter it reads correctly. Turn around and the sweep reads backwards. I confirmed it with a bool print across two networked clients: changing position flipped the result, changing facing never did.
The Solution
I decided to ask the same question in listener space instead. To help me visualize this, I created a graph to show the listener's right vector rotation along the perpendicular of a bullet's travel path.
Drag the slider to spin the listener facing direction. World-space only reacts to position, while listener-space reacts to both.
World space (stock) — ignores facing
dot(bulletRight, perpendicular) = 0
—
Listener space (fix) — follows facing
dot(listenerRight, perpendicular) = 0
—
The function already caches the perpendicular from the bullet's pass point toward the listener, so I swapped the dot product against the camera's right vector (Listener Right) instead of the firing right vector:
bRightToLeft = (dot(ListenerRight, Perpendicular) < 0.0f)
When the listener rotates, the camera's right vector rotates with the listener, so the answer follows the listener's ears. The closest-point spawn, the stereo spread scaled by miss distance, and the distance-based onset delay all stay untouched.
The Result
After swapping the logic, bRightToLeft updates in every orientation, verified from both client perspectives: the bool flips when the firing vector passes the listener's right or left, and is reversed when the listener turns 180°. This is shown in the video above with listener audio (Client 1) from the firing viewpoint (Client 2).
WhizBys are part of the weapon fire path. The full system is covered on the Weapon Audio page. The second case study covers Reflections.