Skip to content

DefaultPlayerOcclusion

Guribo edited this page Jul 11, 2026 · 4 revisions

DefaultPlayerOcclusion

Packages/tlp.udonvoiceutils/Runtime/Core/PlayerAudio/PlayerOcclusion/DefaultPlayerOcclusion.cs

Raycast-based occlusion strategy — the default implementation.

Overview

Casts rays from the listener's head toward the emitter's head. Hits along the ray determine how much audio is muffled.

How It Works

Hits Meaning Result
0 Clear line of sight Full clarity (1.0)
1 One obstacle hit Check distance — if hit is more than 1m from listener, full clarity; otherwise apply obstacle/player clarity
2 Two obstacles hit If both are players → player clarity; otherwise → environment hit clarity

Environment vs Player Occlusion

  • Environment dominates: when any environment hit exists, player occlusion is ignored
  • Player occlusion: only used when both hits are players (no environment between them)
  • AudioObstacle: if present on a hit collider, uses its ObstacleClarity instead of global fallback

Raycast Setup

  • Buffer size: 2 hits
  • Mask: playerOcclusionMask from the active PlayerAudioOverride or PlayerAudioConfigurationModel
  • Player hits detected by null transform (UdonSharp filters player objects)
  • Player occlusion requires the UI layer in the mask — if removed, only environment obstacles affect clarity

Strategy Interface

Extends PlayerOcclusionStrategy — see PlayerOcclusionStrategy for the abstract interface.

See Also

Clone this wiki locally