Skip to content

AudioObstacle

Guribo edited this page Jul 5, 2026 · 5 revisions

AudioObstacle

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

Defines per-obstacle occlusion properties for environment colliders.

Overview

Attach to environment colliders to control how much sound passes through. When a raycast hits this collider during occlusion checks, ObstacleClarity is used instead of the global environment clarity.

Settings

Field Default Range Description
ObstacleClarity 1.0 0-1 0 = fully blocks sound, 1 = fully transparent (no effect)

Setup

  1. Add AudioObstacle component to a collider GameObject
  2. Set ObstacleClarity (0 = wall, 0.5 = muffled, 1 = transparent)
  3. Ensure the collider is on the Environment layer
  4. Walls need collision surface on both sides to work in both directions

Examples

Obstacle Clarity Effect
Solid wall 0.0 Full muffling
Thin curtain 0.7 Slight muffling
Open doorway 1.0 No effect

How It Integrates

The DefaultPlayerOcclusion strategy checks for AudioObstacle on each raycast hit:

  1. Layer mask filters GameObjects first
  2. On hit, GetComponent<AudioObstacle>() is called
  3. If found, uses ObstacleClarity
  4. If not found, uses global environmentClarity fallback

Layer Mask Configuration

The playerOcclusionMask field on PlayerAudioController determines which layers are checked by the raycast:

  • If the UI layer is in the mask, player capsules are detected (enables player occlusion)
  • If UI layer is not in the mask, only environment obstacles are detected

Occlusion Strategies

Strategy Behavior
DefaultPlayerOcclusion Raycast-based, supports AudioObstacle per-obstacle clarity
NullPlayerOcclusion No occlusion (passthrough)

See Also

Clone this wiki locally