internal static void TickAll() { if (SoundEngine == null) { return; } // Adjust spectator position for proper stereo calculation // Check what camera is in use now -> gameplay (player pespective) or custom camera (like some free camera) GTA.Math.Vector3 cameraPos = CameraUtils.IsCameraValid(World.RenderingCamera) ? World.RenderingCamera.Position : GameplayCamera.Position; GTA.Math.Vector3 cameraDir = CameraUtils.IsCameraValid(World.RenderingCamera) ? World.RenderingCamera.Direction : GameplayCamera.Direction; // GameplayCamera gives incorrect position values when player is in car and using first person mode // so we use player head as sound listener if (CameraUtils.IsPlayerUseFirstPerson() && !CameraUtils.IsCameraValid(World.RenderingCamera)) { cameraPos = Main.PlayerPed.Bones[Bone.SkelHead].Position; cameraDir = Main.PlayerPed.Bones[Bone.SkelHead].ForwardVector; } SoundEngine.SetListenerPosition(MathUtils.Vector3ToVector3D(cameraPos), MathUtils.Vector3ToVector3D(cameraDir)); AllAudioEngines.ForEach(x => x.Tick()); }